Commands
Use ↑ ↓ to select a command, to jump between sections.
Movement
forward(n)Move forward n pixels. Alias: fdback(n)Move backward n pixels. Alias: bkleft(degrees)Turn left. Alias: ltright(degrees)Turn right. Alias: rtsetpos(x, y)Move to coordinates (x, y)setheading(angle)Face a direction (0=east, 90=north). Alias: sethhome()Return to center, face eastsetx(x)Set x coordinate, keep ysety(y)Set y coordinate, keep xteleport(x, y)Jump to position instantly, no drawing
Pen
penup()Stop drawing. Alias: pupendown()Start drawing. Alias: pdpensize(n)Set line widthpencolor(r, g, b)Set color with RGB (0–1 or 0–255)pencolor("name")Set color by name: "red", "blue", "gold", etc.color("red")Set both pen and fill colorcolor("red", "blue")Set pen and fill color independently
Shapes
circle(radius)Draw a full circlecircle(radius, extent)Arc: extent in degrees
Fill
begin_fill()Start recording a filled shapeend_fill()Fill the shape drawn since begin_fillfilling()Returns true if currently fillingfillcolor(r, g, b)Set fill colordot(size)Draw a filled circle at turtle's positiondot(size, "red")Draw a dot with a specific color
Text
write(text)Write text at turtle's positionwrite(text, move, align, font)align: "left", "center", "right"; font: {family, size}
Canvas
bgcolor(r, g, b)Set background colorbgcolor("name")Set background color by namescreen_width()Returns canvas width in pixelsscreen_height()Returns canvas height in pixelsclear()Erase drawing, keep turtle positionreset()Erase drawing and reset turtle to startundo()Undo the last commandsetundobuffer(n)Set max undo history lengthspeed(n)0=instant, 1=slowest, 10=fastest
Turtle
hideturtle()Hide the turtle. Alias: htshowturtle()Show the turtle. Alias: ststamp()Stamp turtle shape; returns idclearstamp(id)Remove a stampclearstamps(n)Remove last n stamps; omit n to clear allTurtle()Create a second turtle with all the same methods
State Queries
position()Returns x, y coordinatesxcor() / ycor()Returns x or y coordinateheading()Returns current angle in degreesisdown()Returns true if pen is downisvisible()Returns true if turtle is visibledistance(x, y)Returns distance to pointtowards(x, y)Returns angle towards point
No commands match
Turn on Demos above to see this command in action.
100%
Drag or scroll to pan
Pinch or Ctrl/⌘+scroll to zoom
Drag to pan
Pinch to zoom