Bitmaps and Turtles
Bitmaps are a fundamental part of Logo. A bitmap represents a moveable image on the graphics canvas. Bitmaps can be rotated, stretched, and moved around. A turtle is just a special bitmap that can draw.
These commands handle the number of turtles, how they are created, and how to talk to them.
ARC
Draws an arc; expects between two inputs and three inputs, but parentheses are needed if not called with two inputs.
Syntax
ARC degrees radius
(ARC degrees radius TRUE)
Description
ARC draws an arc, which is part of a circle. The center is the position of the turtle. The arc is drawn with the given radius. It starts at the current heading of the turtle and continues clockwise for the given number of degrees if degrees is positive, or counterclockwise if degrees is negative. The turtle does not move.
If you use TRUE as the third input to ARC, Logo closes the arc by drawing a line from endpoint to endpoint.
Examples
REPEAT 12 [ARC 15 60 RT 30]
BACK
Also: BK
Moves a turtle backwards; one input.
Syntax
BACK number
Description
BACK moves the turtle in the opposite direction of its HEADING by the distance specified by its input. See also FORWARD.
The BACK command works slightly differently for a Blue-Bot robot controlled by Logo via Bluetooth. Blue-Bot moves in fixed-size units. A value of 1 does not mean a single pixel as the screen turtle, but one Blue-Bot movement unit, which is about 6 inches (15 cm). If you, for example, use the command BACK 2, Blue-Bot will move backward one unit, stop briefly, and then move backward a second unit.
For screen widgets, BACK multiplies its input with the turtle’s WIDGET/STEPSIZE property. Setting the WIDGET/STEPSIZE property to, for example 15 (for a Blue-Bot turtle on screen), a turtle would move 15 pixels for each BACK unit.
Examples
BACK 50 BK 50
CTURTLES
Arranges turtles in a circle; one input.
Syntax
CTURTLES number
Description
CTURTLES activates and makes visible the number of turtles specified by its input and arranges them in a circle in the center of the Graphics window.
CTURTLES creates a new set of turtles using the SETTURTLES command.
See also LTURTLES.
Examples
DRAW
CTURTLES 10
FD 40
DISTANCE
Reports the distance between the turtle and a location; expects between one input and two inputs, but parentheses are needed if not called with one input.
Syntax
DISTANCE [x y]
(DISTANCE x y)
Description
DISTANCE reports a number which is the distance in turtle steps from the first active turtle to the specified point. DISTANCE can be used to test how close a turtle is to another turtle, the mouse, or a target.
Examples
ASK 1 [SETPOS [50 50] SHOWTURTLE] ASK 2 [SETPOS [0 50] SHOWTURTLE] DISTANCE ASK 1 [POS] Result: 70.71 DISTANCE ASK 2 [POS] Result: 50
DOT
Draws a dot; expects between zero inputs and two inputs, but parentheses are needed if not called with one input.
Syntax
DOT [xcoordinate ycoordinate]
(DOT xcoordinate ycoordinate)
(DOT)
Description
DOT draws a dot at the specified location. When DOT has no input and is enclosed in parentheses, it draws a pixel at the location of the turtle. When Logo draws a single pixel, it ignores the PENERASE and PENREVERSE modes of the pen; it simply draws the pixel.
DOT draws a dot for each active turtle. If coordinates are given, the coordinates are relative to the origin and scale of each active turtle. The dot is as wide as the pen width set with SETWIDTH.
Examples
TO RANDOM.DOTS :COUNT :AREA
REPEAT :COUNT [DOT SENTENCE RANDOM :AREA RANDOM :AREA]
END
RANDOM.DOTS defined
SETPC “RED
RANDOM.DOTS 300 50
DOT?
Also: DOTP
Tests whether a pixel is present at the given location; expects between zero inputs and two inputs, but parentheses are needed if not called with any inputs.
Syntax
DOT?
(DOT? [xcoordinate ycoordinate])
(DOT? xcoordinate ycoordinate)
Description
DOT? reports TRUE if the pixel identified by its argument has a color that is not fully transparent. The coordinates are the coordinates of the first active turtle. If DOT? is called with a coordinate pair as input (enclosed in parentheses), it uses the given coordinates relative to the origin and scale of the first active turtle.
Note that the background color or image is not part of a drawing, and its color at the given coordinates cannot be examined. If nothing has been drawn at the given location, the color that DOTCOLOR reports would be [0 0 0 0], which is invisible black.
Examples
DOT [50 50] (DOT? [50 50]) Result: TRUE
DOTCOLOR
Reports the color of a pixel; expects between zero inputs and two inputs, but parentheses are needed if not called with one input.
Syntax
DOTCOLOR [xcoordinate ycoordinate]
(DOTCOLOR xcoordinate ycoordinate)
(DOTCOLOR)
Description
DOTCOLOR reports the color of the pixel identified by its argument. The color is reported as a list of Red, Green, Blue and Alpha values. When DOTCOLOR has no input and is enclosed in parentheses, it reports the color of the pixel under the first active turtle. If coordinates are used as input, the coordinates are screen coordinates, with [0 0] at the center.
If the alpha value of the color is 0, the dot is invisible, and the background is visible at that position. Note that the background color or image is not part of a drawing, and its color at the given coordinates cannot be examined. Hence, DOTCOLOR reports the color of a location that has not been drawn onto as [0 0 0 0], which is a fully transparent (invisible) black.
Note that if you draw with a small line width, you may receive a different color than expected, because the drawing algorithm tries to smooth the line by adding or using pixels that do not have the exact same color or alpha value that you used to draw.
EDSHAPE
Launches the shape editor; no inputs.
Syntax
EDSHAPE
Description
Launches the shape editor. For a detailed description, please see the Logo Manual.
FILL
Fills an area; expects between zero inputs and one input, but parentheses are needed if not called with any inputs.
Syntax
FILL
(FILL tolerance)
Description
FILL fills an area of the Graphics panel with the current turtle color; it does not use the current pattern set with the SETPATTERN command. FILL picks up the color at the current turtle position and stops at a closed border of any other color. If the turtle’s pen state is not PENDOWN, FILL does nothing.
Logo supports transparent colors. To make Logo fill transparent colors, FILL accepts a second, optional input. This is a tolerance value between 0 and 1 that affects the way Logo fills transparent colors. A value of 0 makes FILL stop at any color regardless of its transparency, while a value of 1 fills any color, resulting in a complete fill of the entire area. As a default value, Logo uses the value 0.5, which fills all colors that are more than half-transparent.
A clean Graphics panel does not contain any color at all (it is actually pre-filled with a totally transparent black color). When drawing, Logo uses anti-aliasing, which results in smoother lines. Logo does this by adding semi-transparent pixels to the line to create the impression of a smooth line. By using a tolerance value of 0.5, FILL fills these semi-transparent values up to the “real” line. Try, for example, to fill a circle with a tolerance value of 0 to see slight remains of white-looking pixels that Logo refused to fill.
Also, if you fill a colored area with another color, Logo will happily fill the entire screen because it does not stop at the boundary where the initial no-color area begins because of the too-high default tolerance value of 0.5. In this case, (FILL 0) (fill with zero tolerance) also works just fine. Consider this example:
DRAW
; create a filled rectangle
(STAMPRECT 100 100 TRUE)
; move the turtle to the center of the rectangle and fill
PU SETXY [50 50] PD SETPC "RED FILL
This will fill the entire screen, because the starting point is the center of the rectangle (at 50 50). FILL will fill the rectangle, but it won’t stop when it finds a no-color pixel due to the tolerance value. As a result, the entire screen turns red.
If you use (FILL 0), FILL will only fill black pixels, stopping correctly at the no-color pixels.
If you experience color bleeding (Logo fills too much), you could also try to use a line width greater than 1 (see SETWIDTH) to help FILL find the borders to stop at.
Examples
DRAW STAMPOVAL 100 100 SETPC “SADDLEBROWN FILL SETPC “BLACK STAMPOVAL 80 80 SETPC 41 FILL
FONT
Reports the current font of the first active turtle; no inputs.
Syntax
FONT
Description
The FONT command reports the current font of the first active turtle as a three element list consisting of the font name, the font size, and the font attributes.
Examples
FONT Result: [Verdana 9 0]
FONTS
Reports a list of all loaded and available fonts; no inputs.
Syntax
FONTS
Description
The FONTS command reports a list of all available fonts that can be used to print text in the Graphics panel using the TURTLETEXT command.
See also FONT, SETFONT, and TURTLETEXT.
Examples
FONTS Result: [TIMES HELVETICA COURIER SERIF SANS_SERIF MONOSPACE LUMINARI BRADLEY MONACO VERDANA TAHOMA IMPACT]
FORWARD
Also: FD
Moves a turtle forward; one input.
Syntax
FORWARD number
Description
FORWARD moves the turtle in the direction of its HEADING by the distance specified by its input. See also BACK.
The FORWARD command works slightly differently for a Blue-Bot robot. Blue-Bot moves in fixed-size units. A value of 1 does not mean a single pixel as the screen turtle, but one Blue-Bot movement unit, which is about 6 inches (15 cm). If you, for example, use the command FORWARD 2, Blue-Bot will move forward one unit, stop briefly, and then moves forward a second unit.
For screen widgets, FORWARD multiplies its input with the turtle’s WIDGET/STEPSIZE property. Setting the WIDGET/STEPSIZE property to, for example 15 (for a Blue-Bot turtle on screen), a turtle would move 15 pixels for each FORWARD unit.
Examples
FORWARD 50 FD 50
HEADING
Reports the heading of the first active turtle; no inputs.
Syntax
HEADING
Description
HEADING reports the turtle’s heading, a number between 0 and 360, representing the turtle’s angle from the straight up position. Straight up is 0, to the right is 90, down is 180, and to the left is 270.
Use SETHEADING to set the turtle’s heading.
Examples
TO NAUTILUS RT 10 FORWARD HEADING BACK HEADING IF HEADING < 90 THEN NAUTILUS END NAUTILUS defined NAUTILUS
HIDETURTLE
Also: HT
Hides all active turtles; no inputs.
Syntax
HIDETURTLE
Description
HIDETURTLE makes the turtle shape invisible. To make the turtle visible, use SHOWTURTLE. See also SHOWN?.
HOME
Moves the turtle back to [0 0]; no inputs.
Syntax
HOME
Description
HOME moves the turtle to the center of the screen and points the turtle straight up without clearing the graphics screen or altering the pen state. Typing HOME is equivalent to entering SETXY [0 0] SETHEADING 0.
Examples
DRAW TO HEART REPEAT 10 [FD 5 RT 18] REPEAT 22 [FD 3 RT 3] PU HOME PD REPEAT 10 [FD 5 LT 18] REPEAT 22 [FD 3 LT 3] HT END Result: HEART defined HEART
LEFT
Also: LT
Turns a turtle left; one input.
Syntax
LEFT number
Description
LEFT rotates the turtle left (counterclockwise) the number of degrees specified in its input.
Note that a Blue-Bot robot turns in increments of 45 degrees, and an InO-Bot robot turns in increments of 5 degrees. Therefore, the input to LEFT must be a multiple of 45 for Blue-Bot and 5 for InO-Bot. InO-Bot only accepts input values between -180 and 180.
See also RIGHT.
Examples
LEFT 45
LOADSHAPE
Loads a turtle shape from a file and sets the shape of all active turtles; expects between zero inputs and one input, but parentheses are needed if not called with one input.
Syntax
LOADSHAPE filename
LOADSHAPE [extensions-list]
(LOADSHAPE)
Description
LOADSHAPE loads the specified image and sets the shape of all active turtles to that image. If you use LOADSHAPE without inputs, LOADSHAPE opens a dialog box that lets you select a shape to load.
If you use LOADSHAPE without inputs, Logo displays a dialog that lets you select a file name.
If you use a file name instead of a path name and the file was not found, Logo tries to load that file from the “Shapes” toolbox folder. The command LOADSHAPE “~5 would, for example, first try to load the file “~5.png” from the current folder, and then try to load the file from “~HOME/TOOLBOX/SHAPES/~5.PNG”. This is a convenience function that saves you from having to enter a full path when you want to load a file from the “Shapes” folder.
See also LOADSNAP and SETSHAPE.
LOADSNAP
Loads a bitmap; expects between zero inputs and one input, but parentheses are needed if not called with one input.
Syntax
LOADSNAP filename
LOADSNAP [extensions-list]
(LOADSNAP)
Description
LOADSNAP loads the specified file into a newly created BITMAP widget. LOADSNAP can load various bitmap formats. If no extension is given to the filename, the picture format that is attempted to be loaded is the format specified in the göobal variable :PICTURE.FORMAT. If the file has a different extension, then the extension must be specified in the LOADSNAP command. LOADSNAP reports the name of the created widget. This result can be used as the input to SNAP or STAMP, or added to the TELL list.
If you use the command without inputs, Logo displays a dialog that lets you select a file name.
See also SNAPSIZE and SAVESNAP.
Examples
LOADSNAP “~HOME/TOOLBOX/ANIMALS/BEE Result: BITMAP.1
LTURTLES
Arranges turtles in a row; expects between one input and two inputs, but parentheses are needed if not called with one input.
Syntax
LTURTLES number
(LTURTLES number distance)
Description
LTURTLES activates and makes visible the number of turtles specified by its input and arranges them in a horizontal line along the center of the Graphics window. An optional second input specifies the distance in pixels between each turtle, which must be zero or greater. The default distance is 14 pixels.
LTURTLES creates a new set of turtles using the SETTURTLES command.
See also CTURTLES.
Examples
DRAW
LTURTLES 15
FD 100
OPACITY
Reports the opacity of the first active turtle; no inputs.
Syntax
OPACITY
Description
The OPACITY command reports the opacity value of the first active turtle. This is a value between 0 (totally transparent, so it is invisible) and 1 (totally opaque). Setting a value lower than 1 makes the drawing, other widgets beneath the turtle, or the background shine through. See also SETOPACITY.
Examples
OPACITY Result: 1
ORIGIN
Reports the origin of a turtle’s coordinate system; no inputs.
Syntax
ORIGIN
Description
The ORIGIN command reports the coordinate system origin of the first active turtle in the form of a list with two integers: the first integer is the X value and the second integer is the Y value. The coordinates reported by ORIGIN are relative to the standard turtle coordinate system, where [0 0] is the center of the canvas. See also SETORIGIN.
Examples
CS ASK 0 [SETPOS [-25 0] SETORIGIN POS] ASK 1 [SETPOS [25 0] SETORIGIN POS] TELL [0 1] FD 50 RT 135 FD 36 HOME ASK 0 [ORIGIN] Result: [-25 0] ASK 1 [ORIGIN] Result: [25 0]
PANGLE
Reports the turtle’s angle as a polar angle; no inputs.
Syntax
PANGLE
Description
Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics panel and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading equivalent to 90 degrees.
Examples
SETXY [100 100] PANGLE Result: 45 SETXY [0 100] PANGLE Result: 90 SETXY [-100 100] PANGLE Result: 135
PDIST
Reports the distance from the turtle to its home; no inputs.
Syntax
PDIST
Description
PDIST reports the distance from the turtle to its home in the center of the Graphics panel. Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics panel and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading equivalent to 3 o’clock.
Examples
SETXY [100 100] PDIST Result: 141.42 SETXY [0 100] PANGLE Result: 90
PEN
Reports the pen mode; no inputs.
Syntax
PEN
Description
PEN reports the pen mode of the current turtle. Available modes are PENDOWN, PENUP, PENERASE, and PENREVERSE.
Examples
DRAW PEN Result: PENDOWN
PENDOWN
Also: PD
Puts the pen down; no inputs.
Syntax
PENDOWN
Description
PENDOWN puts the turtle’s pen down and causes the turtle to draw a line when it moves. Used in conjunction with PENUP. DRAW puts the pen down. See also PENDOWN?, SETPEN, PENUP, PENERASE, and PENREVERSE.
PENDOWN?
Also: PENDOWNP
Checks whether the pen is down; no inputs.
Syntax
PENDOWN?
Description
PENDOWN? reports TRUE if the pen of the current turtle is in a drawing mode. Thus, it reports TRUE if the pen is set to PENDOWN, PENERASE, or PENREVERSE mode, where the turtle may affect the graphics when it moves. When the pen is set to PENUP mode, PENDOWN? reports FALSE.
Examples
PENDOWN PENDOWN? Result: TRUE PENUP PENDOWN? Result: FALSE PENERASE PENDOWN? Result: FALSE
PENERASE
Also: PE
The pen draws with the background color; no inputs.
Syntax
PENERASE
Description
PENERASE turns the turtle’s pen into an eraser. When the turtle moves, it appears to erase by drawing in the current background color.
Note that PENERASE may leave some residue behind due to an effect called anti-aliasing.
See also PENDOWN, PENUP, PENREVERSE, or SETPEN.
PENREVERSE
Also: PX
The pen inverts all colors; no inputs.
Syntax
PENREVERSE
Description
PENREVERSE inverts the drawing. It erases anything drawn, and draws if there is no drawing.
Note that PENREVERSE may leave some residue behind due to an effect called anti-aliasing.
See also SETPEN, PENDOWN, PENUP, and PENERASE.
PENUP
Also: PU
The pen moves up; no inputs.
Syntax
PENUP
Description
PENUP puts the turtle’s pen up. When the turtle moves, it does not draw a line. Used in conjunction with PENDOWN. See also PENDOWN?, PENERASE, and PENREVERSE.
PHEADING
Reports the turtle’s polar heading; no inputs.
Syntax
PHEADING
Description
Polar coordinates describe positions on the plane in terms of the distance from the turtle’s home and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading that is equivalent to 3 o’clock.
PHEADING reports the polar heading of the turtle. A heading of 0 degrees is equivalent to a Cartesian heading of 90 degrees. Set the polar heading with PSETHEADING.
See also SETP, PPOS, PANGLE, and PDIST.
Examples
SETP 35 60 PSETH 180 PHEADING Result: 180
POS
Also: GETXY
Reports the coordinates of a turtle; no inputs.
Syntax
GETXY
Description
GETXY reports a list consisting of the x and y coordinates of the turtle. GETXY is equivalent to POS. See also GETX, GETY, SETX, SETY, and SETXY.
Examples
GETXY Result: [0 0]
PPOS
Reports the turtle’s polar position; no inputs.
Syntax
PPOS
Description
PPOS reports the turtle’s polar position, a list of two numbers: the distance from home and the polar angle. Set the polar position using SETP. Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics panel and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading equivalent to 3 o’clock. See also PHEADING, PANGLE, and PDIST.
PSETHEADING
Also: PSETH
Sets the polar heading of a turtle; one input.
Syntax
PSETHEADING number
PSETH number
Description
Polar coordinates describe positions on the plane in terms of the distance from the turtle’s home and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading that is equivalent to 3 o’clock. PSETHEADING sets the polar heading of the turtle. A polar heading of 0 degrees is equivalent to 90 degrees in the turtle’s normal (Cartesian) coordinate system. PHEADING reports the polar heading. See also SETP, PPOS, PANGLE, and PDIST.
Examples
SETP 35 60 PSETH 180 PHEADING Result: 180
RIGHT
Also: RT
Turns a turtle right; one input.
Syntax
RIGHT number
Description
RIGHT rotates the turtle right (clockwise) the number of degrees specified in its input.
Note that a Blue-Bot robot turns in increments of 45 degrees, and an InO-Bot robot turns in increments of 5 degrees. Therefore, the input to RIGHT must be a multiple of 45 for Blue-Bot and 5 for InO-Bot. InO-Bot only accepts input values between -180 and 180.
See also LEFT.
Examples
RIGHT 45
SAVESHAPE
Saves the shape of the first active turtle; expects between zero inputs and one input, but parentheses are needed if not called with one input.
Syntax
SAVESHAPE filename
SAVESHAPE [extensions-list]
(SAVESHAPE)
Description
SAVESHAPE saves the shape of the first active turtle or bitmap to a data space. The shape is not saved in a rotated or scaled state.
If you use the command without inputs, Logo displays a dialog that lets you select a file name.
SAVESNAP
Saves a turtle shape; expects between zero inputs and two inputs, but parentheses are needed if not called with two inputs.
Syntax
SAVESNAP turtle filename
(SAVESNAP turtle)
Description
SAVESNAP saves a turtle shape as a bitmap file to a file. The shape is not saved in a rotated or scaled state. These images can be loaded with LOADSNAP, LOADSHAPE or LOADPIC.
SAVESNAP is used to save a bitmap shape that a previous SNAP command has created. It is very similar to the SAVESHAPE command, which saves the shape of the first active turtle.
If you omit the second input, Logo displays a dialog that lets you select a file name.
SETFONT
Sets the turtle drawing font; expects between zero inputs and three inputs, but parentheses are needed if not called with three inputs.
Syntax
SETFONT name size attributes
(SETFONT name size)
(SETFONT name)
(SETFONT)
(SETFONT [name size attributes])
(SETFONT [name size])
(SETFONT [name])
(SETFONT [])
Description
SETFONT defines the turtle font. The first input is the font name. This font should be present in the system. If the font is not present, the operating system selects a similar font for you. The second input is the font size, given in points, while the third is one of the following values:
Value | Effect | Value | Effect |
---|---|---|---|
0 | regular | 2 | italics |
1 | bold | 3 | bold italics |
SETFONT can also be called with fewer than three inputs; in that case, the parts of the font that are not supplied are left unchanged. Calling SETFONT with no inputs causes the font to be reset to the default turtle font. Also, calling SETFONT with a list of zero to three elements makes it possible to match the output of FONT with the input to SETFONT. See also FONT, FONTS and TURTLETEXT.
Examples
SETFONT “TIMES 24 1
TT “HELLO
SETHEADING
Also: SETH
Sets the heading of a turtle; one input.
Syntax
SETHEADING number
Description
SETHEADING turns the turtle to the degree position specified by its input. Positive numbers turn the turtle clockwise.
SETHEADING turns the turtle relative to zero degrees and not the current heading of the turtle. SETHEADING 0 always points the turtle straight up, regardless of the direction in which it is pointing.
To output the turtle’s heading, use HEADING.
Please note that changing the heading makes the bounding box increase and decrease according to the angle.
Examples
TO NAUTILUS RT 10 FORWARD HEADING BACK HEADING IF HEADING < 90 THEN NAUTILUS END Result: NAUTILUS defined NAUTILUS
SETOPACITY
Sets the opacity of all active turtles; one input.
Syntax
SETOPACITY value
Description
The SETOPACITY command sets the opacity value of all active turtles. This is a value between 0 (totally transparent, so they are invisible) and 1 (totally opaque). Setting a value lower than 1 makes the drawing, other widgets beneath the turtles, or the background shine through. See also OPACITY.
Examples
TELL 0 SETOPACITY 0.5 SETTS 2
TELL 1 ST SETTS 2
PU RT 90 FD 60 LT 90 PD
SETOPACITY 0.8
SETORIGIN
Sets the coordinate system origin of the active turtles; expects between zero inputs and one input, but parentheses are needed if not called with one input.
Syntax
SETORIGIN [x y]
(SETORIGIN x y)
(SETORIGIN)
Description
The SETORIGIN command allows the coordinate system origin point to be set for active turtles. Normally, the coordinate system origin (location [0 0]) is at the center of the canvas. This origin may be changed for all turtles or individually for any turtle.
The input for SETORIGIN is a list of two integers, an X value and a Y value. The coordinates are always relative to the standard turtle coordinate system, where [0 0] is the center of the canvas. If you supply a single number, it sets both the X and Y coordinates. (SETORIGIN) resets the origin to the center of the canvas.
Each turtle can have its own origin on the screen.
See also ORIGIN.
Examples
ASK 1 [SETXY [25 0] SETORIGIN POS]
TELL [0 1] ST HOME PD
FD 50 RT 135 FD 36
HOME
SETP
Sets the turtle’s polar position; two inputs.
Syntax
SETP distance angle
Description
SETP sets the turtle’s polar position. It takes two inputs: a distance and a polar angle. It aims the turtle at the specified polar heading and moves it forward the specified distance. Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics panel and the angle from 0 degrees. Polar coordinates measure degrees counterclockwise from a 0 degree heading equivalent to 3 o’clock. See also PHEADING, PANGLE, and PDIST.
Examples
SETP 100 30 Result: **Turtle moves 100 units away from the center with a heading of 60 (= 90 - 30) degrees**
SETPEN
Sets the pen characteristics; one input.
Syntax
SETPEN [penstate pencolor]
Description
SETPEN changes the state of the turtle’s pen and the pen color as specified by its input list. The first element of the list can be PENUP, PENDOWN, PENERASE, or PENREVERSE. The second element is a number from 0 to 138 (the index of a color name that the COLORS procedure returns, a color word or a list of up tp four RGBA values, which specifies the pen color. Use PEN to output the current turtle’s pen state and PENCOLOR to output the current turtle’s pen color. See also SETPC.
Examples
SETPEN [PENDOWN RED]
FD 50
SETSHADOW
Sets the drop shadow for all active turtles; one input.
Syntax
SETSHADOW value
Description
The SETSHADOW command sets the drop shadow for all active turtles. This is a value between 0 and 99, and describes the offset in pixels of the drop shadow. The drop shadow simulates a light source towards the upper left corner of the display. A value of 3, for example, creates a neat little shadow underneath the turtle. See also SHADOW.
Examples
(LTURTLES 8 25)
EACH [SETSHADOW WHO]
SETSHAPE
Sets the shape of all active turtles; expects between zero inputs and one input, but parentheses are needed if not called with one input.
Syntax
SETSHAPE name-of-shape
(SETSHAPE)
Description
SETSHAPE redefines the shape of the active turtle(s). Its input is the name of a bitmap or turtle holding the shape to assign to the active turtle(s). If SETSHAPE is used with no arguments and enclosed in parentheses, the original turtle shape is restored for all active turtle(s).
If the name of the shape does not refer to another bitmap or turtle, SETSHAPE attempts to load a shape from a file just like LOADSHAPE.
Examples
SETSHAPE “TRAIN
SETSPEED
Sets the speed at which turtle commands are executed; one input.
Syntax
SETSPEED number
Description
SETSPEED determines the speed at which the turtles move on the screen when being issued a movement command. SETSPEED accepts a number from 0.1 to 1 as an input. A speed of 1 is the fastest speed and 0.1 is the slowest. When Logo starts, the turtle speed is 1. SETSPEED slows down the execution speed of any movement command. To retrieve the current speed, use SPEED.
SETSPEED sets the value of the turtle’s WIDGET/CRAWL property.
Examples
SETSPEED 0.5 FD 100 SETSPEED 1
SETSTEPSIZE
Sets the step size of all active turtles and bitmaps; one input.
Syntax
SETSTEPSIZE pixels
Description
SETSTEPSIZE sets the distance, in pixels, that Logo turtles and widgets move with each FORWARD or BACK command. SETSTEPSIZE sets this value for all currently active Logo turtles and widgets. By default, each Logo turtle and widget moves in steps of one pixel.
To obtain the step size for a turtle or widget, use STEPSIZE.
Examples
FD 10 SETSTEPSIZE 10 FD 10 SETSTEPSIZE 1 BK 110
SETTURTLENAME
Also: SETTNAME
Sets the name of a turtle; two inputs.
Syntax
SETTURTLENAME turtle name
Description
SETTURTLENAME sets the alias name of the widget whose object name is supplied as its first input. It also sets the widget’s WIDGET/TOOLTIP property. Note that the new name is an alias to the original name; you can use both the original and the alias name to address the widget.
To get the widget alias name, see TURTLENAME.
Examples
SETTNAME 0 “JOE TNAME Result: JOE
SETVELOCITY
Controls the speed of an independently moving widget; one input.
Syntax
SETVELOCITY number
Description
The SETVELOCITY command controls the speed at which a widget moves on the screen independently. A widget is a bitmap, a turtle, or a control. The input is a number between 0 and 500. Any number other than 0 causes the widget(s) to start moving at the given speed, which is approximately the number of pixels (dots) per second. A value of 0 (which is the default) causes the widget to stop moving.
VELOCITY reports the number of pixels per second that a widget moves independently per second.
SETVELOCITY alters the WIDGET/VELOCITY property of all widgets on the TELL list.
Examples
SETVELOCITY 50
SETWIDTH
Also: SETW
Sets the pen width; one input.
Syntax
SETWIDTH number
Description
SETWIDTH defines the width of the line drawn by all active turtles. SETWIDTH takes a number between 1 and 999 as input. WIDTH reports the current line width. See also PENDOWN, PENREVERSE, and PENERASE.
Examples
SETWIDTH 10 FD 50
SETWIDTH 5 FD 50
SETWIDTH 1 FD 50
SETX
Sets the X coordinate of a turtle; one input.
Syntax
SETX x-coordinate
Description
SETX moves the turtle horizontally to the point specified by the input number. SETX does not affect the turtle’s heading or its Y coordinate. See also SETY, SETXY, GETX, GETY, and GETXY.
Examples
HOME
SETX 45
SETXY
Also: SETPOS
Sets the coordinates of a turtle; expects between one input and two inputs, but parentheses are needed if not called with one input.
Syntax
SETXY [x-coordinate y-coordinate]
(SETXY x-coordinate y-coordinate)
Description
SETXY moves the turtle to the point specified by its inputs. SETXY does not affect the turtle’s heading. To obtain the X and Y coordinates of the turtle, use GETXY or the equivalent command, POS. SETXY accepts a two-element list of coordinates or two numeric inputs.
See also SETX, SETY, GETX, GETY, and GETXY.
Examples
HOME
SETXY [50 50]
SETY
Sets the Y coordinate of a turtle; one input.
Syntax
SETY y-coordinate
Description
SETY moves the turtle vertically to the point specified by the input number. SETY does not affect the turtle’s heading or its X coordinate. See also SETX, SETXY, GETX, GETY, and GETXY.
Examples
HOME
SETY 45
SHADOW
Reports the drop shadow for the first active turtle; no inputs.
Syntax
SHADOW
Description
The SHADOW command reports the drop shadow for the first active turtle. This is a value between 0 and 99, and describes the offset in pixels of the drop shadow. The drop shadow simulates a light source towards the upper left corner of the display. A value of 3, for example, creates a neat little shadow underneath the turtle. The initial value is 0, which means no shadow at all. See also SETSHADOW.
Examples
SHADOW Result: 0
SHAPE
Outputs the name of the first active turtle’s shape; no inputs.
Syntax
SHAPE
Description
SHAPE reports the name of the shape of the current turtle. The name of the turtle’s default shape is the empty name. Use SETSHAPE or LOADSHAPE to alter the shape of a turtle.
Examples
SHAPE Result:
SHOWN?
Also: SHOWNP
Reports whether a turtle is visible; no inputs.
Syntax
SHOWN?
Description
SHOWN? reports TRUE if the first active turtle is currently displayed on the graphics screen; otherwise, it reports FALSE. See also HIDETURTLE and SHOWTURTLE.
SHOWTURTLE
Also: ST
Makes a turtle visible; no inputs.
Syntax
SHOWTURTLE
Description
SHOWTURTLE makes all active turtles visible. To make the turtles invisible, use HIDETURTLE. See also SHOWN?.
SLOWTURTLE
Slows down the turtle to half speed; no inputs.
Syntax
SLOWTURTLE
Description
SLOWTURTLE slows down the execution speed of any movement commend. It is equivalent to the command SETSPEED 0.5. Use SETSPEED 1 to restore the turtle speed.
To retrieve the current speed, use SPEED.
Examples
SLOWTURTLE SPEED Result: 0.5 SETSPEED 1
SPEED
Reports the speed at which turtle commands are executed; no inputs.
Syntax
SPEED
Description
SPEED reports the current speed at which the turtle(s) moves on the screen. When Logo starts, the turtle speed is 1. Values range from 0.1 to 1; the lower the value is, the slower the turtle moves. Use SETSPEED to change the speed.
Examples
SPEED Result: 1
STAMPOVAL
Draws an oval; expects between two inputs and four inputs, but parentheses are needed if not called with two inputs.
Syntax
STAMPOVAL xradius yradius
(STAMPOVAL xradius yradius "TRUE)
(STAMPOVAL xradius yradius "TRUE angle)
Description
STAMPOVAL draws an oval around the current turtle(s). It takes two numbers as inputs. The first input is the oval’s radius in the horizontal direction; the second input is its radius in the vertical direction. STAMPOVAL draws a circle if the two inputs are equal. If STAMPOVAL, its inputs, and the value TRUE are all enclosed in parentheses, the oval drawn is filled with the current pattern in the current pen color. If the turtle’s pen state is PENDOWN, STAMPOVAL colors the area with the current pen color. If the pen state is PENERASE, STAMPOVAL colors the area with the current background color, thus erasing the form. If the pen state is PENREVERSE, STAMPOVAL colors the area with the complement of the current area color; for example, white turns to black, and green to red. If the turtle’s pen state is PENUP, STAMPOVAL has no effect.
The fourth optional input is the angle to use when stamping. If not otherwise specified, a value of 0 is used, which causes the oval to be stamped with the xradius in horizontal and the yradius in vertical direction. If an angle is given, the oval is rotated to the given number of degrees.
To stamp an oval of 50x100 pixels in the heading of the current turtle, for example, use (STAMPOVAL 50 100 FALSE HEADING)
See also STAMPRECT and STAMPRECTC.
Examples
STAMPOVAL 100 100
(STAMPOVAL 50 50 TRUE)
STAMPRECT
Draws a rectangle; expects between two inputs and four inputs, but parentheses are needed if not called with two inputs.
Syntax
STAMPRECT width height
(STAMPRECT width height "TRUE)
(STAMPRECT width height fill angle)
Description
STAMPRECT draws a rectangle with a width in turtle steps defined by its first input and a height defined by its second input. The rectangle is drawn with the current turtle position in the lower left corner. STAMPRECT draws a square if the two inputs are equal. If STAMPRECT, its inputs, and the value TRUE are all enclosed in parentheses, the rectangle drawn is filled with the current pattern in the current pen color,
If the turtle’s pen state is PENDOWN, STAMPRECT colors the area with the current pen color. If the pen state is PENERASE, STAMPRECT colors the area with the current background color, thus erasing the form. If the pen state is PENREVERSE, STAMPRECT colors the area with the complement of the current area color; for example, white turns to black, and green to red. If the turtle’s pen state is PENUP, STAMPRECT has no effect.
The fourth optional input is the angle to use when stamping. If not otherwise specified, a value of 0 is used, which causes the rectangle to be stamped with the width in the horizontal direction and the height in the vertical direction. If an angle is given, the rectangle is rotated to the given number of degrees.
To draw a rectangle centered around the turtle’s position and with the same angle as the turtle’s heading, use STAMPRECTC.
See also STAMPRECTC and STAMPOVAL.
Examples
SETPC “RED
(STAMPRECT 40 60 “TRUE)
PU SETX 75 PD
SETPC “SILVER
(STAMPRECT 40 60 “TRUE)
SETPC “BLACK
STAMPRECT 40 60
STAMPRECTC
Draws a rectangle centered around the turtle position; expects between two inputs and four inputs, but parentheses are needed if not called with two inputs.
Syntax
STAMPRECTC width height
(STAMPRECTC width height "TRUE)
(STAMPRECTC width height fill angle)
Description
STAMPRECTC draws a rectangle with a width in turtle steps defined by its first input and a height defined by its second input. The rectangle is drawn with the current turtle position centered around the turtle. STAMPRECT draws a square if the two inputs are equal. If STAMPRECTC, its inputs, and the value TRUE are all enclosed in parentheses, the rectangle drawn is filled with the current pattern in the current pen color.
The turtle draws the rectangle in the same angle as its heading if you do not supply an angle as its fourth input.
If the turtle’s pen state is PENDOWN, STAMPRECTC colors the area with the current pen color. If the pen state is PENERASE, STAMPRECTC colors the area with the current background color, thus erasing the form. If the pen state is PENREVERSE, STAMPRECTC colors the area with the complement of the current area color; for example, white turns to black, and green to red. If the turtle’s pen state is PENUP, STAMPRECTC has no effect.
See also STAMPRECT and STAMPOVAL.
Examples
SETPC “RED
(STAMPRECTC 40 60 “TRUE)
PU SETX 75 PD
SETPC “SILVER
(STAMPRECTC 40 60 “TRUE)
SETPC “BLACK
STAMPRECTC 40 60
STEPSIZE
Outputs the step size of the first active turtle or bitmap; no inputs.
Syntax
STEPSIZE
Description
STEPSIZE outputs the distance, in pixels, that Logo turtles and widgets move with each FORWARD or BACK command, for the first active turtle or widget. By default, each Logo turtle and widget moves in steps of one pixel.
To set the step size, see SETSTEPSIZE.
Examples
FD 10 SETSTEPSIZE 10 FD 10 STEPSIZE
TOWARDS
Reports the angle of a position compared to the turtle position; one input.
Syntax
TOWARDS [xcoordinate ycoordinate]
Description
TOWARDS reports a number that is the heading that will point the turtle to the position specified by its input list. SETHEADING TOWARDS [xcoordinate ycoordinate] heads the turtle in the direction of its input list.
Examples
ST SETH 0 SETH TOWARDS [100 100]
TURTLENAME
Also: TNAME
Gets the name of the first active turtle; no inputs.
Syntax
TURTLENAME
Description
TURTLENAME outputs the name of the first active turtle. This is also the value of its WIDGET/NAME property.
To set the turtle name, see SETTURTLENAME.
Examples
SETTNAME 0 “JOE TNAME Result: JOE
TURTLENAMES
Also: TNAMES
Outputs a list of all turtle names; no inputs.
Syntax
TURTLENAMES
Description
TURTLENAMES outputs a list of the names of all turtles. Note that this list does not output turtle numbers, but names if a turtle has been given an alias name. Use ALLTURTLES to obtain a list of turtle numbers.
See also TURTLENAME and SETTURTLENAME.
Examples
TURTLENAMES Result: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 JOE JACK]
TURTLES
Reports the number of turtles; no inputs.
Syntax
TURTLES
Description
The TURTLES command reports the total number of available turtles. Set the number of turtles with SETTURTLES. See also TELLALL, ALLTURTLES, TELLEVEN, and TELLODD.
Examples
TURTLES Result: 16
TURTLESIZE
Also: TSIZE
Reports the scaling factor of a turtle; no inputs.
Syntax
TURTLESIZE
Description
TURTLESIZE reports a number, the scaling factor of the current turtle. A turtle’s scaling factor can be in the range of 0.1 to 99. If the turtle’s scaling factors are different for the width and height, TURTLESIZE reports a two-element list with the scaling factors for the turtle’s width and height.
To set the turtle’s size, use SETTURTLESIZE.
TURTLETEXT
Also: TT
Prints its input on the Graphics panel; expects between one input and two inputs, but parentheses are needed if not called with one input.
Syntax
TURTLETEXT whatToPrint
(TURTLETEXT whatToPrint mode)
Description
TURTLETEXT prints its input (word or list) on the Graphics panel at the position of the current turtle. TURTLETEXT prints in the pen color and font of the current turtle. TURTLETEXT has no effect if the turtle’s pen is up.
TURTLETEXT prints text into a box whose top left corner is at the turtle’s location. If you want to use multiple fonts in one line, this is bad because font sizes vary, and the text is not lined up neatly. Therefore, an optional second input defines where the text should be drawn. There are three possible values:
-
TOP: The turtle position is the top left of the text box. This is the default.
-
BOTTOM: The turtle position is the bottom left of the text box.
-
BASELINE: The turtle draws text with the turtle’s Y coordinate set to the baseline of the text, which is an imaginary line that you would use to write text on. This causes the text to be vertically aligned.
The example below demonstrates the three modes of drawing text.
See also FONT, SETFONT, TURTLETEXTSIZE and FONTS.
Examples
TO TTPRINT :LIST :BASE
DRAW.LINE :BASE
FOREACH :LIST [
(SETFONT FIRST ?)
LMAKE “TEXT BF ?
LMAKE “WIDTH FIRST TTSIZE :TEXT
PD (TT :TEXT :BASE) PU
RT 90 FD :WIDTH LT 90
]
END
Result: TTPRINT defined
TO DRAW.LINE :BASE
LMAKE “Y YCOR
SETFONT “ARIAL 14 0
PD SETPC “GREEN RT 90 FD 300 SETH 0 TT :BASE
SETPC “BLACK PU SETXY LIST 0 :Y SETH 0
END
Result: DRAW.LINE defined
DRAW
MAKE “LIST [
[[Arial 16] |It ain’t over |]
[[TIMES 12] |until the |]
[[TIMES 22 3] |Fat |]
[[TIMES 22 0] |Lady |]
[[TIMES 18] |sings.|]
]
PU SETXY [0 100]
TTPRINT :LIST “BASELINE
PU SETXY [0 70]
TTPRINT :LIST “TOP
PU SETXY [0 0]
TTPRINT :LIST “BOTTOM
PU SETY -50
TURTLETEXTSIZE
Also: TTSIZE
Outputs the dimensions of a text drawn with the first listening turtle; one input.
Syntax
TURTLETEXTSIZE "text
Description
The TURTLETEXTSIZE command is convenient if you want to erase the background before drawing a text, or if you want to advance the turtle behind or below the text after drawing a text.
See also FONT, SETFONT and FONTS.
Examples
TTSIZE “HELLO Result: [21 14]
VELOCITY
Reports the speed of an independently moving widget; no inputs.
Syntax
VELOCITY
Description
VELOCITY reports the number of pixels per second that a widget (a bitmap, a turtle, or a control) moves independently per second. Use the SETVELOCITY command to control this speed.
VELOCITY reports the name ot the first active widget’s WIDGET/VELOCITY property.
Examples
VELOCITY Result: 0
WIDTH
Reports the pen width; no inputs.
Syntax
WIDTH
Description
WIDTH reports the pen width of the first active turtle. The pen width can be a number between 1 and 99. The pen width is set using the command SETWIDTH. If more than one turtle is active, the pen width of these turtles may be interrogated with WIDTH and the ASK or EACH command.
Examples
DRAW WIDTH Result: 1 TELL [0 1 2 3 4] SETWIDTH 5 EACH [PRINT WIDTH] Result: 5 5 5 5 5
GETX
Also: XCOR
Reports the X coordinate of a turtle; no inputs.
Syntax
GETX
Description
GETX outputs the X coordinate of the turtle’s position in the Graphics panel. See also GETY, GETXY, SETX, SETY, and SETXY.
Examples
GETX Result: 0
GETY
Also: YCOR
Reports the Y coordinate of a turtle; no inputs.
Syntax
GETY
Description
GETY outputs the Y coordinate of the turtle’s position in the Graphics panel. See also GETY, GETXY, SETX, SETY, and SETXY.
Examples
GETY Result: 0
SETTURTLES
Also: SETT
Creates a range of turtles; one input.
Syntax
SETTURTLES number
Description
SETTURTLES defines the total number of turtles available. Their numbers range from 0 to the input of SETTURTLES minus 1. For example, SETTURTLES 16 will create the turtles [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]. By default, Logo starts with 16 turtles defined and turtle 0 activated.
SETTURTLES creates turtles with the following characteristics:
Property | Value |
---|---|
Turtle number | 0 |
Turtle name | TURTLE |
Turtle color | 0 (black) |
Turtle size | 1 |
Heading | 0 |
Line width | 1 |
Visible | FALSE |
Pattern | 0 |
Pen state | PENUP |
Font | Default system font, 9 points |
Please note that turtle #0’s pen is down (PENDOWN), and it is visible. Turtle 0 is the only one that is activated (see TELL).
SETTURTLES accepts a number between 1 and 1000 as input. The actual maximum of turtles depends on the speed of the computer. The more turtles you set, the slower turtle movements become.
TURTLES reports the number of turtles that have been defined with SETTURTLES. Use the TELL, ASK, EACH, and WHO commands to access multiple turtles.
Examples
SETTURTLES 4 TURTLES Result: 4
LOCKSHAPE
Prevents a bitmap from turning; no inputs.
Syntax
LOCKSHAPE
Description
LOCKSHAPE prevents the shapes for all active turtles and bitmaps from rotating when the widget turns. This can be convenient when you want the shape to appear in its current orientation and size, regardless of how you turn the turtle or bitmap.
The command HEADING always reports the true heading of the widget. Use UNLOCKSHAPE to restore the shape’s visual orientation to match its heading.
Examples
DRAW SETSPEED .8 SETH 45 FD 100 LOCKSHAPE RT 90 WAIT 500 UNLOCKSHAPE
SETTURTLESIZE
Also: SETTSIZE, SETTS
Sets the scaling factor of a bitmap; expects between one input and two inputs, but parentheses are needed if not called with one input.
Syntax
SETTURTLESIZE number
SETTURTLESIZE [x-scale y-scale]
(SETTURTLESIZE x-scale y-scale)
Description
SETTURTLESIZE sets the scaling factor of the bitmap. The input number(s) must be in the range of -99 to 99, where 0.01 indicates an almost invisibly small bitmap, and 99 the largest possible bitmap. As the size of the turtle increases, its shape becomes more jagged. If SETTURTLESIZE is used with two inputs, or with a two-element list, the first input is the horizontal scaling factor, and the second input is the vertical scaling factor.
If a value is negative, it causes the shape to flip either horizontally, vertically, or both. Examples:
(SETTURTLESIZE -1 1) flips horizontally at a size of 1.
(SETTURTLESIZE 1 -1) flips vertically at a size of 1.
(SETTURTLESIZE -0.5 0.5) makes the turtle half the size and flips it horizontally.
(SETTURTLESIZE 1 5) Creates a long turtle that has 5 times the height as usual.
SETTURTLESIZE 2 is the same as (SETTURTLESIZE 2 2) or SETTURTLESIZE [2 2].
The command TURTLESIZE reports the size of the first bitmap of the TELL list.
Please note that changing the scaling factor does not change the bitmap’s real size. It only scales the bitmap.
Note that turtles also are bitmaps.
Examples
TELL [0 1 2]
ST
EACH [PU SETX 100 * WHO SETTURTLESIZE WHO + 1]
UNLOCKSHAPE
Lets a bitmap rotate according to the turtle’s heading; no inputs.
Syntax
UNLOCKSHAPE
Description
UNLOCKSHAPE restores the normal rotation of the bitmap, cancelling the effects of LOCKSHAPE. The bitmap immediately returns to the orientation that most accurately represents its true heading.
Examples
DRAW SETSPEED .8 SETH 45 FD 100 LOCKSHAPE RT 90 WAIT 500 UNLOCKSHAPE