forward
fdforward distance
Move the turtle forward by the given number of steps.
Logo Trail reference
Every drawing command in Logo Trail, grouped so you can find what you need fast. Click an example to copy it into your notebook.
Move the turtle forward and backward.
forward distance
Move the turtle forward by the given number of steps.
back distance
Move the turtle backward without turning around.
home
Send the turtle back to the center of the canvas.
pos
Reports the turtle position as a list [x y] in Logo coordinates.
xcor
The turtle’s horizontal position (0 is center).
ycor
The turtle’s vertical position (positive is up).
Change which way the turtle is facing.
right degrees
Turn the turtle to the right by the given angle in degrees.
left degrees
Turn the turtle to the left by the given angle in degrees.
setheading angle
Point the turtle in an exact direction (0 = up, 90 = right).
heading
Reports which way the turtle is facing, in degrees.
towards [x y]
Reports the heading angle needed to face the point [x y].
Jump the turtle to a specific spot.
setxy x y
Move the turtle to coordinates x and y on the canvas.
setx x
Change only the horizontal position.
sety y
Change only the vertical position.
setpos [x y]
Move using a two-item list, same idea as setxy.
arc angle radius
Draw part of a circle while moving along the arc.
ellipse crosswise inline
Draw an ellipse centered on the turtle. First number is the semiaxis perpendicular to heading; second is along heading. The turtle does not move.
Control whether the turtle leaves a trail.
penup
Lift the pen so movement does not draw a line.
pendown
Lower the pen so the turtle draws again.
setpensize width
Make lines thicker or thinner.
fill
Flood-fill the closed shape around the turtle with the current pen color. Draw a closed outline first, move inside, then fill.
filled color [ commands ]
Draw the commands in the brackets, then fill the shape they outline (like jslogo). The color is the fill; the pen color draws the border.
penerase
Erase lines as the turtle moves (like a rubber).
penreverse
Reverse pen mode — lines invert the colors underneath.
label text
Writes text at the turtle’s position, in the current pen color.
showturtle
Shows the turtle sprite on the canvas.
hideturtle
Hides the turtle sprite (drawing still works).
Paint with color and reset the canvas.
help command
Show a tip from the turtle helper about a command.
setcolor name
Set the pen color using a name, number, or RGB list.
setbackground color
Fill the canvas background with a color.
clean
Erases the drawing but keeps the turtle where it is.
clearscreen
Erase all drawings and reset the turtle to the center.
pencolor
Reports the current pen color.
background
Reports the canvas background color.
palette n
Reports the color name for palette number n (0–15).
wait milliseconds
Pause briefly so you can watch the turtle move step by step.
Repeat code and choose different paths.
repeat count [ ... ]
Run the commands inside the brackets that many times.
if condition [ ... ]
Run the block only when the condition is true.
ifelse condition [ ... ] [ ... ]
Run the first block when true, otherwise the second. Alias: elseif.
greater? a b
True when the first number is bigger than the second (use inside if).
less? a b
True when the first number is smaller than the second.
for [var start end] [ ... ]
Runs a loop with a counter variable from start to end.
while [ condition ] [ ... ]
Repeats the block while the condition is true.
forever [ ... ]
Keep running the block until you stop the program.
Teach the turtle new commands with to … end. Run the definition once, then call it by name from any cell.
to name [filled [color]] … end
Start a new procedure (function). Write the body on the lines below, then end on its own line. Run the cell once to load it—the turtle remembers it for later cells. Use **filled** after the name to record the body as a path and polygon-fill when done; an optional palette number sets fill (and pen) color (e.g. `to box filled 2`).
end
Finishes a procedure started with to. Put end on its own line after the last command in the body.
to name :arg1 :arg2
Add inputs after the procedure name. Inside the body, :arg1 and :arg2 read the values you pass in when you call the procedure.
name value1 value2
Run a procedure you defined. Use the name like a command. Pass one value per input, in the same order as in the to line.
stop
Exit the current procedure right away—useful inside if when a recursion should end.
output value
Return a value from a procedure (for advanced programs).
Save values and reuse them with :name.
make "name value
Store a value in a variable. Use :name to read it later.
repcount
Inside repeat, gives the current loop number (1, 2, 3…).
Use numbers and randomness in your art.
sum a b
Add two numbers together.
difference a b
Subtract the second number from the first.
product a b
Multiply two numbers.
quotient a b
Divide the first number by the second.
random max
Pick a random whole number from 0 up to max − 1 (or random A B for A through B inclusive).
pick list
Chooses one random item from a list (great with color names).
power base exp
Raises a number to a power.
print thing
Show a value in the output area (great for debugging).
show thing
Print a value with quotes stripped from words (easier to read).
minus number
Flip the sign of a number (make positive negative or vice versa).
Paste a copied example into the Draw page, press Run, and watch the turtle go.
62 commands documented · Logo Trail