Welcome to JP's Web Logo

Quick Start

Try telling the turtle to draw a square by typing this command four times:

a square fd 50 rt 90

Change the 90 to 120, 72, 45 or 144 to change the shape to a triangle, pentagon, octagon or five-pointed star.

You can send the turtle home and clear the screen by typing:

home cs

To repeat a command several times, use the repeat command:

an octagon repeat 8 [fd 50 rt 45]

A circle can be drawn as a many-sided shape, like this:

a circle repeat 180 [fd 3 rt 2]

To get fancy, use a repeat command inside another repeat command:

Fancy circularly-symmetrical line drawing repeat 10 [repeat 5 [fd 50 rt 72] rt 36]

Use setxy and random to scribble lines all over the screen:

a bunch of sribbled lines repeat 200 [setxy random * 600 - 300 random * 600 - 300]

Teach the turtle new commands using the to command, or make changes to them using the edit command:

to star repeat 5 [fd 50 rt 144] end to star
edit star

Challenges

  1. Try drawing a five-pointed star without the interior lines. If you have trouble, ask somebody who's good at math to help you figure out the angles. line drawing of a five-pointed star without lines crossing through the middle
  2. Try drawing a car. For this challenge, it's a good idea to define a car command (using to and edit) so you can experiment and easily redo the drawing. Begin the car command with home cs. a simple line-drawing of a car
  3. Use the descriptions below to learn how to change the turtle's pen color, how to hide and show the turtle, and how to switch to and from fullscreen mode.

Turtle Commands

fd (forward) :dist

Move the turtle forward by the given distance.

bk (back) :dist

Move the turtle backward by the given distance.

rt (right) :angle

Rotate the turtle clockwise by the given angle.

lt (left) :angle

Rotate the turtle counterclockwise by the given angle.

pu (penup)

Disable the turtle's pen so it won't draw lines when moving.

pd (pendown)

Enable the turtle's pen so it will draw lines when moving.

ht (hideturtle)

Make the turtle invisible.

st (showturtle)

Make the turtle visible.

pw (penwidth) :width

Set the width of the lines that the turtle draws.

pc (pencolor) :color

Set the turtle's pen color to one of 16 different colors. :color can be any number, but it is converted to an integer and reduced into the range 0-15.

setxy :x :y

Move the turtle directly to position (:x, :y). As usual, if the turtle's pen is down, it will draw a line as it moves.

home

Move the turtle to its home position of (0, 0), which is the center of the screen in fullscreen mode. As usual, if the turtle's pen is down, it will draw a line as it moves.

cs (clearscreen)

Clear the screen.

Screen Mode Commands

fs (fullscreen)

Set the screen mode to fullscreen. You can use the Escape key to exit back to splitscreen mode.

ss (splitscreen)

Set the screen mode to splitscreen (the default mode).

ts (textscreen)

Set the screen to textscreen (full text) mode. When in textscreen mode, running any turtle command will restore the screen back to splitscreen mode. You can also get to textscreen mode by pressing Escape when in splitscreen mode.

State Commands

currentx, currenty

Returns the turtle's current x or y coordinate.

currentheading

Returns the current rotation angle of the turtle as an angle between -180 and 180.

currentwidth, currentheight

Returns the current width or height of the screen in the turtle's native coordinates. The larger of the two dimensions is always exactly 600. In splitscreen mode, the height includes the part of the screen that is obscured by the text console. In other words, the height does not change when switching between textscreen, splitscreen and fullscreen modes. You can use these commands to move the turtle to the top-left corner of the screen:

setxy currentwidth / -2 currentheight / 2

currentspeed

Returns the current program speed, as set by the speed command.

Procedure Commands

to procedure-name :args ...

Opens the full-screen editor to start defining a new procedure. For example:

to polygon :length :sides

This will start defining a new procedure that accepts two parameters named :length and :sides. When done defining the procedure, you can save it by clicking the Save button at the bottom of the editor screen.

The given procedure name must not be defined yet. To edit an existing procedure, use the edit command instead.

Defined procedures are preserved in your web browser's local storage when you close and re-open this web page. They are also shared across browser tabs if you have the page open in multiple tabs.

edit procedure-name

Opens the full-screen editor to start editing an existing procedure. For example:

edit polygon

Unlike the to command, you don't need to pass the parameter names.

procs

Returns a list of all currently defined procedures.

del procedure-name

Deletes a procedure.

clear

Deletes all procedures. This command brings up a confirmation dialog to ensure you really meant to run it.

end

This command marks the end of the procedure in the full-screen editor. When used in any other context, it has no effect.

Variable Commands

make :var-name :value

Defines a global variable. For example:

make "a 57
fd :a

The above sequence defines a variable named :a with the value 57. It then tells the turtle to move forward :a, which causes a move of 57 units.

local :var-name :value

Defines a local variable. This is identical to make, except that the created variable is only visible in the context of the procedure in which it's defined. Local variables have the same scope as parameters that are passed into a procedure. The local command can be used to change the value of procedure parameters.

vars

Returns the list of currently defined global variables.

locals

Returns the list of local variables defined in the current context.

Control Flow Commands

if :condition :list

Executes the commands in the given list if the condition is true. Examples:

if 5 < 6 [show "Yes!] if "true [show "Yes!] if "false [show "Nope.]

ifelse :condition :list1 :list2

Executes either :list1 or :list2, depending on whether the condition is true or false (respectively).

repeat :n :list

Executes the given list :n times.

stop

Interrupts program execution. This does the same thing as pressing Escape while a program is running. The cont command can be used to resume the program from where it left off.

cont

Resumes a stopped program.

Math Commands

sin :angle

Returns the sine of the given angle (in degrees).

cos :angle

Returns the cosine of the given angle (in degrees).

tan :angle

Returns the tangent of the given angle (in degrees).

floor :value

Rounds the given value down.

random

Returns a random number in the range [0, 1).

List and String Manipulation Commands

box :value

Returns a list containing just the provided value.

join :list-or-string1 :list-or-string2

Concatenates the given lists or strings into a longer list or string.

get :list-or-string :index

Returns the list element or character at the specified position in the given list or string.

slice :list-or-string :start-index :length

Returns a sub-list or substring of the given list or string, with the specified length, beginning at the specified index.

length :list-or-string

Returns the length of the given list or string.

File Management Commands

save :filename

Saves all currently defined procedures into a file with the given name. If the file already exists, it is overridden.

load :filename

Loads procedures from the given file. Any procedures that were defined before the load command are erased.

scratch :filename

Deletes the file with the given filename.

files

Returns a list of all saved files.

Miscellaneous Commands

speed :speed

Set the program speed. The speed can be any positive integer, but if the number gets too large, the speed won't increase much more, and it may become more difficult to interrupt a long-running program.

builtins

Returns a list of all built-in commands.

help

Shows this help page.

show :value

Displays a given value in the console.


About JP's Web Logo

Logo is an educational programming language designed in 1967 by Wally Feurzig, Seymour Papert and Cynthia Solomon. Many dialects of Logo have been created for many platforms.

JP's Web Logo was created by John-Paul Gignac. It's intended to be a simple, minimal Logo dialect with a friendly interface. It's primarily inspired by the Commodore 64 Logo by MIT and Terrapin.