Welcome to the Turtle Graphics page! Here, you can write turtle-style scripts to draw on the canvas below. Use simple commands to move the turtle, control the pen, and create fun shapes or patterns. Try out the sample script or make your own. Click "run" to see your drawing come to life!
You can tell the turtle what to draw by writing commands! The turtle starts in the middle of the canvas facing up. Write your commands and click "run" to see the magic happen!
Make the turtle walk forward or backward:
move forward 50 steps
move backward 30 steps
Make the turtle turn left or right:
turn 90 degrees to the right
turn 45 degrees to the left
A full circle is 360 degrees. 90 degrees is a right angle (like a corner of a square).
Control when the turtle draws:
lower pencil (start drawing)
raise pencil (stop drawing, move without drawing)
When the pencil is "lowered", the turtle draws a line as it moves. When it's "raised", the turtle moves without drawing.
You can use these colors: blue, red, green, yellow, black, white, orange, purple, brown, grey, fuchsia, maroon, rebeccapurple
use pencil of colour red
use pencil of colour blue
Make the line thicker or thinner:
use pencil of size 5
use pencil of size 10
Bigger numbers make thicker lines!
You can save numbers with names to use later:
size = 50
move forward size steps
Now you can use "size" instead of writing 50 every time!
You can do math with numbers:
+ for addition (5 + 3 = 8)- for subtraction (10 - 4 = 6)* for multiplication (3 * 4 = 12)/ or : for division (12 / 3 = 4)^ for power (2 ^ 3 = 8, which is 2×2×2)sqrt for square root (sqrt(16) = 4)distance = 20 + 30
move forward distance steps
Draw the same thing many times with a "for" loop:
for i from 1 to 4
move forward 50 steps
turn 90 degrees to the right
end
This draws a square! The turtle repeats the commands inside 4 times.
You can also use a "while" loop to repeat while something is true:
i = 0
while i < 10
move forward 10 steps
turn 36 degrees to the left
i = i + 1
end
This keeps going while i is less than 10, drawing a circle!
Make the turtle do different things based on conditions:
if x > 100
then
turn 90 degrees to the left
else
move forward 10 steps
end
You can compare numbers with: == (equal), != (not equal), > (greater), < (less), >= (greater or equal), <= (less or equal)
lower pencil
use pencil of colour blue
use pencil of size 3
for i from 0 to 4
move forward 100 steps
turn 90 degrees to the right
end
raise pencil
lower pencil
use pencil of colour yellow
use pencil of size 5
for i from 1 to 6
move forward 80 steps
turn 144 degrees to the right
end
raise pencil
lower pencil
use pencil of colour green
s = 1
for i from 1 to 80
move forward s steps
turn 18 degrees to the left
s = s + 1
end
raise pencil