Skip to content
Sign upLog in
← Back to Community
How to draw Pixel Art on Python with Turtle!
Profile icon
John_WardWard

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 t=turtle.Turtle() wn=turtle.Screen() 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:
t.speed(0)
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.forward(20) 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): t.begin_fill() square() t.color("Blue") t.end_fill() t.color("Black") t.forward(20)

We created this function. Now we may uses it whenever we like with this command:
Tetris_Piece_1().
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!
t.pensize(4)

Voters
Profile icon
ChasHanna
Profile icon
ThaisDuarte
Profile icon
o0mar50
Profile icon
MrsCanapetti
Profile icon
SamuelHawley
Profile icon
Bluejaylia4
Profile icon
tinydiamond
Profile icon
whattyu
Profile icon
Mehedi08
Profile icon
Haricharan2010
Comments
hotnewtop
Profile icon
nothplus

Good Job John!

Profile icon
John_WardWard

@nothplus
Thanks!

Profile icon
Mohanad_Alaas

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

Profile icon
John_WardWard

@Mohanad_Alaas Sure, Done it now.

Profile icon
nothplus

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

Profile icon
John_WardWard

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

Profile icon
nothplus

@John_WardWard Ok John whats your name I need to PM

Profile icon
John_WardWard

@nothplus

TheLegendJohnWard

Profile icon
nothplus

@John_WardWard CHeck it, ur discord and stay active

Profile icon
MaxCosta

@John_WardWard Lookin good dude!

Profile icon
timmy_i_chen

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

Profile icon
John_WardWard

@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.

Profile icon
ChloeDaulby

Hey everyone I am new to pixel art but I am very excited to try something different in my retirement.

Profile icon
[deleted]

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

Profile icon
John_WardWard

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

Profile icon
OWENBIRMINGHAM

Noiiiice

Profile icon
KaydenKulp

it did not work

Profile icon
Torbyn1234

i like it

Profile icon
Torbyn1234

hmm

Profile icon
Gegette

pas fou fou ceci

Profile icon
hunylee

Good!! John

Profile icon
Logimite

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

Profile icon
John_WardWard

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

Profile icon
Logimite

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

Profile icon
falcon21

@laksh5
haha I'm looking at THIS one year later

Profile icon
tinydiamond

@falcon21
and me ANOTHER year

Profile icon
Logimite

@tinydiamond
hi there!

Profile icon
[deleted]

This is amazing! I really like the pacman design!

Profile icon
John_WardWard

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

Profile icon
[deleted]

This is sick nice job! You get my upvote!

Profile icon
John_WardWard

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

Profile icon
[deleted]

@John_WardWard Thanks!

Profile icon
JannisFreund

it's nice to see that some people come up with the same idea i had. i did mine a bit differently though... but still very nice! :)

Profile icon
itspranshu

Good Job John! Nice, People will like it very much👍

Profile icon
Rayan81

Wow 🤩 cool

Profile icon
LitteJohn

That is a nice drawing I will use for something as wee thank you so much!!!

Profile icon
Renise

That is amazinggg

Profile icon
MOULYANAGARAJNA

thanks for this I got a better idea how to draw\

Profile icon
SeamusDonahue

I made this from what I learned here! https://repl.it/@SeamusDonahue/tetrominos

Profile icon
TheBananaTux

Yes top notch!

Profile icon
AshCodz

cool!

Profile icon
featlixma

nice john

Profile icon
stubaduble

@John_WardWard
how do you make the block appear?

Profile icon
Cookiezz

@stubaduble
He defined a "Tetris Piece". He then executes the command to draw the "Tetris Piece". Code to the "Tetris Piece":

def Tetris_Piece_1() for x in range(4): t.begin_fill() square() t.color("Blue") t.end_fill() t.color("Black") t.forward(20)

To execute the command, he writes Tetris_Piece_1() in his code.

Profile icon
stubaduble

This does not work for me..

Profile icon
cutyonfortnite

Really nice !

Profile icon
Wilke000

Wow, @John_WardWard, you did a great job!

Profile icon
[deleted]

This is really great!

Profile icon
KlayerDavid

12 Karten mit den Lieblings-Pokémon Ihrer Kinder: Pikachu, Glumanda, Bulbasaur, Squirtle, Celébi, Charizard, Eevee, Mew, Roudoudou und mehr. Es ist eine großartige Aktivität, um Konzentration zu entwickeln, die sie lange beschäftigen wird! Mehr sehen: Pixel Art Pokemon

Profile icon
tinydiamond

Oh wow! That's cool!