Terrapin Resources

Turtle Drawing

Move turtles around, and make them draw.

Turtle movement commands control the direction of the turtle movement. Drawing commands draw arcs, text, or fill areas.

All commands that accept a coordinate pair accept one of the following inputs:

  • No inputs: use the turtle’s coordinates.
  • One input: if the input is a number, use that number for both the X and Y coordinates; if it is a list, it is a two-element list with the X and Y coordinates.
  • Two inputs: use the two numbers as X and Y coordinates.

Examples:

Note that the background color or image is not part of a drawing, and its color cannot be examined.

Please also not that most commands are also valid for controls as well; controls act exactly like turtles, they just cannot draw because they do not have a pen. Therefore, we often use the word “widget”, which addresses turtles as well as controls.

ARC

Draws an arc.

Syntax

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 counter-clockwise 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.

Example

REPEAT 12 [ARC 25 100 RT 30]

BACK

Also: BK

Moves a turtle backwards.

Syntax

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. 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 STEPSIZE property. Setting the STEPSIZE property to, for example 15 (for a Blue-Bot turtle on screen), a turtle would move 15 pixels for each BACK unit.

Example

BACK 50 BK 50

DISTANCE

Reports the distance between the turtle and a location.

Syntax

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.

Example

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.

Syntax

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. 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.

Example

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.

Syntax

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.

Example

DOT [50 50] (DOT? [50 50]) Result: TRUE

DOTCOLOR

Reports the color of a pixel.

Syntax

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.

FILL

Fills an area.

Syntax

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:

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.

Example

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.

Syntax

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.

See also SETFONT and FONTS.

Example

FONT Result: [Verdana 9 0]

FONTS

Reports a list of all loaded and available fonts.

Syntax

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.

FONTS Result: [TIMES HELVETICA COURIER SERIF SANS_SERIF MONOSPACE LUMINARI BRADLEY MONACO VERDANA TAHOMA IMPACT]

FORWARD

Also: FD

Moves a turtle forward.

Syntax

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 STEPSIZE property. Setting the STEPSIZE property to, for example 15 (for a Blue-Bot turtle on screen), a turtle would move 15 pixels for each FORWARD unit.

Example

FORWARD 50 FD 50

GETX

Also: XCOR

Reports the X coordinate of a turtle.

Syntax

Description

GETX outputs the X coordinate of the turtle’s position in the Graphics canvas. See also GETY, GETXY, SETX, SETY, and SETXY.

Example

GETX Result: 0

GETXY

Also: POS

Reports the coordinates of a turtle.

Syntax

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.

Example

GETXY Result: [0 0]

GETY

Also: YCOR

Reports the Y coordinate of a turtle.

Syntax

Description

GETY outputs the Y coordinate of the turtle’s position in the Graphics canvas. See also GETX, GETXY, SETX, SETY, and SETXY.

Example

GETY Result: 0

HEADING

Reports the heading of a turtle.

Syntax

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.

Example

TO NAUTILUS RT 10 FORWARD HEADING BACK HEADING IF HEADING < 90 THEN NAUTILUS END NAUTILUS defined NAUTILUS

HIDETURTLE

Also: HT

Hides a turtle.

Syntax

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].

Syntax

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.

Example

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 HEART defined HEART

LEFT

Also: LT

Turns a turtle left.

Syntax

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.

Example

LEFT 45

OPACITY

Reports the opacity of the first active turtle.

Syntax

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.

Example

OPACITY Result: 1

ORIGIN

Reports the origin of a turtle’s coordinate system.

Syntax

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.

Example

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.

Syntax

Description

Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics canvas and the angle from 0 degrees. Polar coordinates measure degrees counter-clockwise from a 0 degree heading equivalent to 3 o’clock.

PDIST

Reports the distance from the turtle to its home.

Syntax

Description

PDIST reports the distance from the turtle to its home in the center of the Graphics canvas. Polar coordinates describe positions on a plane in terms of the distance from the turtle’s home in the center of the Graphics canvas and the angle from 0 degrees. Polar coordinates measure degrees counter-clockwise from a 0 degree heading equivalent to 3 o’clock.

PEN

Reports the pen mode.

Syntax

Description

PEN reports the pen mode of the current turtle. Available modes are PENDOWN, PENUP, PENERASE, and PENREVERSE.

Example

DRAW PEN

PENDOWN

Also: PD

Puts the pen down.

Syntax

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, PENERASE, and PENREVERSE.

PENDOWN?

Also: PENDOWNP

Checks whether the pen is down.

Syntax

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.

Example

PENDOWN PENDOWN? Result: TRUE PENUP PENDOWN? Result: FALSE PENERASE PENDOWN? Result: FALSE

PENERASE

Also: PE

The pen draws with the background color.

Syntax

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. To stop PENERASE, use PENDOWN, PENUP, PENERASE, or SETPEN.

PENREVERSE

Also: PX

The pen inverts all colors.

Syntax

Description

PENREVERSE inverts the drawing. It erases anything drawn, and draws if there is no drawing. Note hat due to anti-aliasing, some residue may be left when a drawing is erased.

Please also note thet PENREVERSE works differently from Logo 4, where the colors were inverted.

DRAW puts the pen down. See also SETPEN, PENDOWN, PENUP, and PENERASE.

PENUP

Also: PU

The pen moves up.

Syntax

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.

Syntax

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 counter-clockwise 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.

Example

SETP 35 60 PSETH 180 PHEADING Result: 180

PPOS

Reports the turtle’s polar position.

Syntax

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 canvas and the angle from 0 degrees. Polar coordinates measure degrees counter-clockwise 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.

Syntax

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 counter-clockwise 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.

Example

SETP 35 60 PSETH 180 PHEADING Result: 180

Also: RT

Turns a turtle right.

Syntax

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 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 LEFT.

Example

RIGHT 45

SETFONT

Sets the turtle drawing font.

Syntax

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 a combination of the following values:

   
0 regular
1 bold
2 italic
3 bold italic

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.

Example

SETFONT “TIMES 14 1 TT “HELLO

SETHEADING

Also: SETH

Sets the heading of a turtle.

Syntax

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 does not change the physical size, although the bounding box increases and decreases according to the angle. If used inside a grid, the size of grid cell does not adjust to the rotated widget.

Example

TO NAUTILUS RT 10 FORWARD HEADING BACK HEADING IF HEADING < 90 THEN NAUTILUS END NAUTILUS defined NAUTILUS

SETOPACITY

Sets the opacity of all active turtles.

Syntax

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.

Example

SETOPACITY 0.8

SETORIGIN

Sets the coordinate system origin of the active turtles.

Syntax

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.

Example

ASK 1 [SETXY [25 0] SETORIGIN POS] TELL [0 1] ST FD 50 RT 135 FD 36 HOME

SETP

Sets the turtle’s polar position.

Syntax

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 canvas and the angle from 0 degrees. Polar coordinates measure degrees counter-clockwise from a 0 degree heading equivalent to 3 o’clock. See also PHEADING, PANGLE, and PDIST.

SETPEN

Sets the pen characteristics.

Syntax

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 163 (the index of a color name that the COLORS procedure returns, a color word or a list of three RGB 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.

Example

SETPEN [PENDOWN RED] FD 50

SETSHADOW

Sets the drop shadow for all active turtles.

Syntax

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.

Example

; set the shadow distance according to the turtle’s Z-order TELLALL 0 15 EACH [SETSHADOW GPROP WHO “Z.ORDER]

SETSPEED

Sets the speed at which turtle commands are executed.

Syntax

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 commend. To retrieve the current speed, use SPEED.

SETSPEED sets the value of the turtle’s CRAWL property.

Example

SETSPEED 0.5 FD 100 SETSPEED 1

SETSTEPSIZE

Sets the step size of all active turtles and bitmaps.

Syntax

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.

Example

FD 10 SETSTEPSIZE 10 FD 10 SETSTEPSIZE 1 BK 110

SETTURTLESIZE

Also: SETTSIZE, SETTS

Sets the scaling factor of a widget.

Syntax

Description

SETTURTLESIZE sets the scaling factor of the widget. The input number(s) must be in the range of -99 to 99, where 0.01 indicates an almost invisibly small widget, and 99 the largest possible widget. 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 widget of the TELL list.

Please note that changing the scaling factor does not change the physical size. If used inside a grid, the size of grid cell does not adjust to the scaled widget.

Example

TELL [0 1 2] ST EACH [PU SETX 100 * WHO SETTURTLESIZE WHO + 1]

SETVELOCITY

Controls the speed of an independently moving widget.

Syntax

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 VELOCITY property of all widgets on the TELL list.

Example

SETVELOCITY 50

SETWIDTH

Also: SETW

Sets the pen width.

Syntax

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.

Example

(FOR “W 30 1 [SETWIDTH :W PD FD 3] -1)

SETX

Sets the X coordinate of a turtle.

Syntax

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.

Example

HOME SETX 45

SETXY

Also: SETPOS

Sets the coordinates of a turtle.

Syntax

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.

Example

HOME SETXY [50 50]

SETY

Sets the Y coordinate of a turtle.

Syntax

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.

Example

HOME SETY 45

SHADOW

Reports the drop shadow for the first active turtle.

Syntax

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.

Example

SHADOW Result: 0

SHOWN?

Also: SHOWNP

Reports whether a turtle is visible.

Syntax

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.

Syntax

Description

SHOWTURTLE makes the turtle shape visible. To make the turtle invisible, use HIDETURTLE. See also SHOWN?.

SLOWTURTLE

Slows down the turtle to half speed.

Syntax

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.

Example

SLOWTURTLE SPEED Result: 0.5 SETSPEED 1

SPEED

Reports the speed at which turtle commands are executed.

Syntax

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.

Example

SPEED Result: 1

STAMPOVAL

Draws an oval.

Syntax

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.

Example

STAMPOVAL 100 100 (STAMPOVAL 50 50 TRUE)

STAMPRECT

Draws a rectangle.

Syntax

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 stamp a rectangle of 50x100 pixels in the heading of the current turtle, for example, use

(STAMPRECT 50 100 FALSE HEADING)

See also STAMPOVAL.

Example

SETPC “RED (STAMPRECT 40 60 “TRUE) PU SETX 75 PD SETPC “SILVER (STAMPRECT 40 60 “TRUE) STAMPRECT 40 60

STEPSIZE

Outputs the step size of the first active turtle or bitmap.

Syntax

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.

Example

FD 10 SETSTEPSIZE 10 FD 10 STEPSIZE

TOWARDS

Reports the angle of a position compared to the turtle position.

Syntax

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.

Example

ST SETH 0 SETH TOWARDS [100 100]

TURTLESIZE

Also: TSIZE

Reports the scaling factor of a turtle.

Syntax

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 canvas.

Syntax

Description

TURTLETEXT prints its input (word or list) on the Graphics canvas 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.

See also FONT, SETFONT, TURTLETEXTSIZE and FONTS.

Example

TURTLETEXT [HELLO WORLD]

TURTLETEXTBASE

Also: TTBASE

Outputs the baseline offset of the first listening turtle’s font.

Syntax

Description

The TURTLETEXT command draws text using the bounding text box, and the turtle positioned at the top left corner of that box. When drawing text in different sizes, you would want to align the text at the baseline of that font. The baseline is the imaginary line that you would use to write on if you wrote the text yourself.

To get the size of the bounding box of a text, see TURTLETEXTSIZE. See also FONT, SETFONT, and FONTS.

Example

; assume that the baseline is at 0 DRAW PU SETH 90 SETFONT “TIMES 22 0 SETY TTBASE PD TT “|Logo | PU FD FIRST TTSIZE “|Logo | SETFONT “TIMES 14 0 SETY TTBASE PD TT “|Logo| PU FD FIRST TTSIZE “|Logo|

TURTLETEXTSIZE

Also: TTSIZE

Outputs the dimensions of a text drawn with the first listening turtle.

Syntax

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. To align text with different sizes, see TURTLETEXTBASE.

See also FONT, SETFONT and FONTS.

Example

; assume that the baseline is at 0 DRAW PU SETH 90 SETFONT “TIMES 22 0 SETY TTBASE PD TT “|Logo | PU FD FIRST TTSIZE “|Logo | SETFONT “TIMES 14 0 SETY TTBASE PD TT “|Logo| PU FD FIRST TTSIZE “|Logo|

VELOCITY

Reports the speed of an independently moving widget.

Syntax

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 VELOCITY property.

Example

VELOCITY Result: 0

WIDTH

Reports the pen width.

Syntax

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.

Example

DRAW WIDTH Result: 1 TELL [0 1 2 3 4] SETWIDTH 5 EACH [PRINT WIDTH] 5 5 5 5 5