Logo Trail reference

Command cheat sheet

Every drawing command in Logo Trail, grouped so you can find what you need fast. Click an example to copy it into your notebook.

🐢

Movement

Move the turtle forward and backward.

forward

fd

forward distance

Move the turtle forward by the given number of steps.

back

bk

back distance

Move the turtle backward without turning around.

home

home

Send the turtle back to the center of the canvas.

pos

pos

Reports the turtle position as a list [x y] in Logo coordinates.

xcor

xcor

The turtle’s horizontal position (0 is center).

ycor

ycor

The turtle’s vertical position (positive is up).

🔄

Turning

Change which way the turtle is facing.

right

rt

right degrees

Turn the turtle to the right by the given angle in degrees.

left

lt

left degrees

Turn the turtle to the left by the given angle in degrees.

setheading

seth

setheading angle

Point the turtle in an exact direction (0 = up, 90 = right).

heading

heading

Reports which way the turtle is facing, in degrees.

towards

towards [x y]

Reports the heading angle needed to face the point [x y].

📍

Position

Jump the turtle to a specific spot.

setxy

setxy x y

Move the turtle to coordinates x and y on the canvas.

setx

setx x

Change only the horizontal position.

sety

sety y

Change only the vertical position.

setpos

setpos [x y]

Move using a two-item list, same idea as setxy.

arc

arc angle radius

Draw part of a circle while moving along the arc.

ellipse

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.

✏️

Pen

Control whether the turtle leaves a trail.

penup

pu

penup

Lift the pen so movement does not draw a line.

pendown

pd

pendown

Lower the pen so the turtle draws again.

setpensize

setwidthsetpw

setpensize width

Make lines thicker or thinner.

fill

fill

Flood-fill the closed shape around the turtle with the current pen color. Draw a closed outline first, move inside, then fill.

filled

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

pe

penerase

Erase lines as the turtle moves (like a rubber).

penreverse

px

penreverse

Reverse pen mode — lines invert the colors underneath.

label

label text

Writes text at the turtle’s position, in the current pen color.

showturtle

st

showturtle

Shows the turtle sprite on the canvas.

hideturtle

ht

hideturtle

Hides the turtle sprite (drawing still works).

🎨

Colors & screen

Paint with color and reset the canvas.

help

help command

Show a tip from the turtle helper about a command.

setcolor

setpencolorsetpccolor

setcolor name

Set the pen color using a name, number, or RGB list.

setbackground

setbgsetscreencolorsetsc

setbackground color

Fill the canvas background with a color.

clean

clean

Erases the drawing but keeps the turtle where it is.

clearscreen

csclear

clearscreen

Erase all drawings and reset the turtle to the center.

pencolor

pc

pencolor

Reports the current pen color.

background

bg

background

Reports the canvas background color.

palette

palette n

Reports the color name for palette number n (0–15).

wait

wait milliseconds

Pause briefly so you can watch the turtle move step by step.

🔁

Loops & decisions

Repeat code and choose different paths.

repeat

repeat count [ ... ]

Run the commands inside the brackets that many times.

if

if condition [ ... ]

Run the block only when the condition is true.

ifelse

elseif

ifelse condition [ ... ] [ ... ]

Run the first block when true, otherwise the second. Alias: elseif.

greater?

greaterp

greater? a b

True when the first number is bigger than the second (use inside if).

less?

lessp

less? a b

True when the first number is smaller than the second.

for

for [var start end] [ ... ]

Runs a loop with a counter variable from start to end.

while

while [ condition ] [ ... ]

Repeats the block while the condition is true.

forever

forever [ ... ]

Keep running the block until you stop the program.

Define functions

Teach the turtle new commands with to … end. Run the definition once, then call it by name from any cell.

to

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

end

Finishes a procedure started with to. Put end on its own line after the last command in the body.

procedure inputs

inputs:size:name

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.

call a procedure

call

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

stop

Exit the current procedure right away—useful inside if when a recursion should end.

output

op

output value

Return a value from a procedure (for advanced programs).

📦

Variables

Save values and reuse them with :name.

make

make "name value

Store a value in a variable. Use :name to read it later.

repcount

#

repcount

Inside repeat, gives the current loop number (1, 2, 3…).

🔢

Math & helpers

Use numbers and randomness in your art.

sum

sum a b

Add two numbers together.

difference

difference a b

Subtract the second number from the first.

product

product a b

Multiply two numbers.

quotient

quotient a b

Divide the first number by the second.

random

random max

Pick a random whole number from 0 up to max − 1 (or random A B for A through B inclusive).

pick

pick list

Chooses one random item from a list (great with color names).

power

power base exp

Raises a number to a power.

print

pr

print thing

Show a value in the output area (great for debugging).

show

show thing

Print a value with quotes stripped from words (easier to read).

minus

minus number

Flip the sign of a number (make positive negative or vice versa).

Try it on the canvas

Paste a copied example into the Draw page, press Run, and watch the turtle go.

62 commands documented · Logo Trail