How to Draw With Turtle

by build it code it use it in Craft > Art

1052 Views, 2 Favorites, 0 Comments

How to Draw With Turtle

Screenshot 2021-02-09 at 2.19.44 PM.png

Hello, and welcome to the instructable. I will be teaching you how to draw with code. you might be thinking, draw with code, you are crazy. The next thing you might think is, oh ok he used scratch. No, Drawing with turtle is best for shapes with perfect symmetry.

Supplies

Any devise with a keyboard/mouse (at least 4 gigs of ram recommended, anything from 2014 and newer)

Getting Started

Screen Shot 2021-02-02 at 1.19.10 PM.png

The first thing you want to do is go to a site that supports python, I would go to https://repl.it/. You do not have to login. If you do not login then skip to step three.

Logging In

Screenshot 2021-02-09 at 2.42.49 PM.png

To login or sign up (sIgning up is free) simply just click sign up (or login if you already have an account.) when you click sign up it will ask your username DO NOT USE YOUR EMAIL ADRESS. The username is the name you will go by I would recommend just putting your first and last name. Next put in a strong password with at least 6 digits. Once you click next it will ask what skill level are you, It does not matter what you put just fill it in or click skip. Then it will say what are you interested in, you can click any of them. Now an important part, It will ask what languages are you interested in you HAVE to click on python, You have to choose two others (I would recommend LUA and JAVA) once you. when you scroll down it will say introduce yourself to the community, get started coding, and start with a tutorial, click on get started coding, and click on the plus sign in the top right corner and name the code turtle and click on python for your language. now you are ready to get started

Get Turtle

Screenshot 2021-02-09 at 2.46.12 PM.png

When you start any turtle code you have to import turtle like in the image above. All you have to do is type:

from turtle import*

then hit return once or twice, now you are ready.

!Important! Make sure you click the shell button. The default setting is on consol but you have to click shell which is right above the code and right of the console button. Once you click shell click run, when you click run a box that says "turtle graphics" should pop up in the output zone.

The Basic Rules

Screenshot 2021-02-09 at 2.47.18 PM.png

before we start drawing crazy shapes you have to know a few things. One, when you do a forward command,forward(how far you want to go goes in the parenthasis) it only goes in the direction that the cursor is facing. When you type right() or left() The angle you want to go goes inside the parenthasis.

Getting Started

Screenshot 2021-02-09 at 3.19.29 PM.png

Once you have imported turtle you are ready to start. In the image above I made a simple square, If you can make a polygon that is not a square (because that was my code and you can just copy off of it) then you are ready for the next step.

Penup Pendown

Screenshot 2021-02-10 at 7.43.04 PM.png

Penup(you put nothing inside these parenthasis) and pendown(same here) codes are quite easy, it is just the understanding the setposition(put the x,y cordinates in here) that gets tricky. Imagine the turtle workspace thing (not the imput) as a large cordinate plane and where you start is (0,0) or the origin (you learn this in either 4th or 5th grade) every forward you go goes along the cordinate plane. when you do penup() it lifts the pen and moves to the location where you want and then you do pendown() and you can continue drawing.

here is a code for a shape and when you see the circle commands do not panic just scroll down I will teach.

from turtle import*from turtle import*

circle(50)

penup()

setposition(-10,50)

pendown()

circle(10)

penup()

setposition(-10,55)

pendown()

circle(2.9)

circle(2.8)

circle(2.7)

circle(2.6)

circle(2.5)

circle(2.4)

circle(2.3)

circle(2.2)

circle(2.1)

circle(2)

circle(1.9)

circle(1.8)

circle(1.7)

circle(1.6)

circle(1.5)

circle(1.4)

circle(1.3)

circle(1.2)

circle(1.1)

circle(1)

circle(0.9)

circle(0.8)

circle(0.7)

circle(0.6)

circle(0.4)

circle(0.5)

circle(0.3)

circle(0.2)

circle(0.1)

penup()

setposition(10,50)

setposition(10,50)

pendown()

circle(10)

penup()

setposition(10,55)

pendown()

circle(2.9)

circle(2.8)

circle(2.7)

circle(2.6)

circle(2.5)

circle(2.4)

circle(2.3)

circle(2.2)

circle(2.1)

circle(2)

circle(1.9)

circle(1.8)

circle(1.7)

circle(1.6)

circle(1.5)

circle(1.4)

circle(1.3)

circle(1.2)

circle(1.1)

circle(1)

circle(0.9)

circle(0.8)

circle(0.7)

circle(0.6)

circle(0.4)

circle(0.5)

circle(0.3)

circle(0.2)

circle(0.1)

penup()

setposition(-16,25)

pendown()

circle(60,60)

Circles and Arcs

Screenshot 2021-02-10 at 7.48.50 PM.png

Making a circle is just as easy as making a straight line, all you have to do is just type circle(the radius of the circle goes in here.) but an arc is like that multiplication that is little bit harder then that addition. When drawing an arc (part of a circle) you type the circle command circle(), then you type the distance of the arc, yours should look like circle(12) 12 was the example. Next you need to add the angle your arc goes. 180 degrees is useless because you can just do a forward command and it goes the same distance. 360 degrees is useless too because you can just do a normal circle command. but if you wanted to draw the smiley face's mouth you need arcs. so just like for the ordered pair you need to add a comma circle(12,), then you need to add the angle. circle(12,72) 72 was an example.

Ninja Turtles?

Screenshot 2021-02-11 at 7.49.05 AM.png

Oh no, A new word. when you look at the image above and see all of that scary code you would probably check if you missed a few steps but you did not. The first thing that you will notice is I did not import turtle the same way as normal.When you import turtle while using ninja you have to just say 'import turtle', when done hit return a few times, and type ninja=turtle.turtle(). Nothing goes in the parenthasis, we just defined ninja. now we have to set the speed which is easy all you have to do is ninja.speed(recommended 10-100). now you have to set the range/repeat. The repeat command for python is pretty easy all it is is, 'for i in range(180):'. 180 is how many times you go around.

do not forget the colon. Now you make one line that can be squigly or straight and with angles just before every forward left right command add a ninja.forward or right or left. in the parenthasis you normally type how many times you want the code to run. once done do right(2) penup() setposition(0,0) and pendown()

When you do for i in range() what should go in the parenthasis is 360/ the number inside the parenthasis for the right command.

the code should look like this so far.

import turtle
ninja=turtle.Turtle()

ninja.speed(10)

for i in range(180):

ninja.forward(10)

ninja.left(88)

ninja.forward(60)

ninja.right(23)

ninja.forward(60)

ninja.penup()

ninja.setposition(0,0)

ninja.right(2)

ninja.pendown()

turtle.done()

Make It Real

Screenshot 2021-02-11 at 9.14.14 AM.png

Now that you are the ninja master of turtle, You can make much more then shapes on a screen you can make shapes in real life. If you find the right software you can run a code and print the net on paper and have your very own 3-d shape.

In the End

Screenshot 2021-02-11 at 9.20.09 AM.png

Now that I taught you pretty much everything you need to know why don't you comment some shapes that you made (digital or in real life). I feel like I learned something in the making of this instructable. Nothing left to say except for...

If you made it down here you are cool.😎😎