Learn to Code via Tutorials on Repl.it

← Back to all posts
How to draw Pixel Art on Python with Turtle!
John_WardWard (230)

How to Draw Pixel Art on Python with Turtle!

In this Tutorial you shall learn how to create your own pixel art on Python with Turtle, I hope you enjoy.

The first step to creating our art is to import turtle and set a background. My personal tip is to use black as it works best with pixel art.

Here is model code:

import turtle
wn.bgcolor("Black")                     #Remember Speech Marks.

Then, for step 2, we will set the speed of your turtle to be a high value, using this command:
Then, now the technical aspects are over with, let us get into the real juicy code!

First, we must define square. My optimum size after a lot of testing was a 20 by 20 square. You define a function using this piece of code:

def square():
       for x in range(4):
             t.right(90)                                              #Remember Indentation.

Then, After that step, we can start making pixel art!
To add colours to our squares, we use the begin_fill command. Let me show an example about how this works.

def Tetris_Piece_1():
  for x in range(4):

We created this function. Now we may uses it whenever we like with this command:
This code will make a Horizontal line of 4 pixels, like the Tetris piece! Look at the example below to see Pac-Man also.

You've come to the end of the Tutorial. However, if you would like to extend this, here are some ideas.

Find a way to define Red_Square or Blue_Square.

Make a video-game character.

Create a model of a Tetris screen.

It has lots of uses, so try it today.

Remember to click on Python with Turtle and not python 2.7, Python or Django.

I recommend you watch the example in larger screen by pressing Open in Repl.it.

Special Credit to JSer for teaching me how to use markdown on this post!

Up the pensize to 4 if you want it really blocky using this command!

Mohanad_Alaas (4)

@John_WardWard John be sure to support my Tutorial if you really liked it!

nothplus (68)

@John_WardWard John you got discord, if not get it and let me add you

John_WardWard (230)

@nothplus Yea , I'm on the repl.it server:)

nothplus (68)

@John_WardWard Ok John whats your name I need to PM

nothplus (68)

@John_WardWard CHeck it, ur discord and stay active

DragonLord5646 (33)

Nice! I've been having trouble with pixel art. This should take care of it! I've got to make each pixel smaller though.

John_WardWard (230)

@DragonLord5646 That's really nice to hear! Making pixels smaller should add a more refined image! I'm glad to know I helped!

timmy_i_chen (1045)

You should use markdown to style your post, it will make the code much easier to read :)

John_WardWard (230)

@timmy_i_chen Thanks for the advice. I'll fix it up tomorrow though as I'm in the U.K and it's getting late.


This is sick nice job! You get my upvote!

John_WardWard (230)

@IEATPYTHON Thanks. I upvoted your Colourful circle generator. That was amazing! It was very complex, and made a very eye-pleasing pattern!

laksh5 (119)

How did you put the code in that cool way? Also, remember to support my tutorial.

John_WardWard (230)

@laksh5 You use Markdown. Timmy Chen showed me a tutorial from an amazing person called JSer. I'll link his tutorial.

laksh5 (119)

@John_WardWard I got it thanks! I'm looking at this after 1 year XD.

HarditSingh1 (1)

This is really great!


This is amazing! I really like the pacman design!

John_WardWard (230)

@ChillBreeze Thanks. The capabilities are large for what you can create with this Code!

bananajoe3 (0)

that was really cool! thanks

JellyBean85 (0)

omg. john the bomb

JohnHunter3 (2)

epic tutorial i already knew most of this but its nice to get a refresher