Terrapin Resources

Turtle Shapes

The commands in this group load, change, and lock turtle images. A turtle shape is an image file that can be loaded from the cloud storage.

LOADSHAPE

Loads a turtle shape from a data space and sets the shape of all active turtles.

Syntax

Description

LOADSHAPE loads the specified image and sets the shape of all active turtles to that image. If you use LOADSHAPE without inputs, LOADSHAPE resets the active turtles to their default shape.

If you use a list of file extensions as the file name, Logo displays a Select File dialog with the list of files limited to the ones matching the list of extensions. Logo also supports old-style Terrapin Logo typelists, but their use is not recommended. See SELECT.FILE for more information.

Please note that you cannot select a disk file in the browser-based version of Logo.

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.

EDSHAPE

Launches the shape editor.

Syntax

Description

Launches the shape editor. For a detailed description, please see the Logo Manual.

LOADSNAP

Loads a bitmap.

Syntax

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 built-in 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 a list of file extensions as the file name, or use the command without inputs, Logo displays a Select File dialog with the list of files limited to the ones matching the list of extensions. Logo also supports old-style Terrapin Logo typelists, but their use is not recommended. See SELECT.FILE for more information.

See also SNAPSIZE and SAVESNAP.

Example

LOADSNAP “~HOME/TOOLBOX/ANIMALS/BEE Result: BITMAP.1

LOCKSHAPE

Prevents a bitmap from turning.

Syntax

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.

Example

SAVESHAPE

Saves the shape of the first active turtle.

Syntax

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. The file format is PNG.

If you use a list of file extensions as the file name, or use the command without inputs, Logo displays a Select File dialog with the list of files limited to the ones matching the list of extensions. Logo also supports old-style Terrapin Logo typelists, but their use is not recommended. See SELECT.FILE for more information.

SAVESNAP

Saves a turtle shape.

Syntax

Description

SAVESNAP saves a turtle shape as a bitmap file a data space. The shape is not saved in a rotated or scaled state. The file format is PNG. 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 use a list of file extensions as the file name, or use the command without inputs, Logo displays a Select File dialog with the list of files limited to the ones matching the list of extensions. Logo also supports old-style Terrapin Logo typelists, but their use is not recommended. See SELECT.FILE for more information.

SETSHAPE

Sets the shape of all active turtles.

Syntax

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.

See also SHAPE and LOADSHAPE.

Example

Changes the shape of all active turtles to the shape of turtle 15.

SETSHAPE 15 SETSHAPE 9999 Error: File /9999.png not found

SHAPE

Outputs the name of the first active turtle’s shape.

Syntax

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.

Example

SHAPE Result:

SNAP

Moves parts of the Graphics panel into a bitmap.

Syntax

Description

SNAP reports a region of the Graphics panel as a newly created bitmap. The position of the first active turtle marks the lower left corner, while the inputs describe the size of the image to be SNAPped in pixels. The bitmap that SNAP reports may be saved, loaded, or STAMPed.

The optional third input is either “BACKGROUND to snap the background only, “DRAWING to snap the drawing only, or “BOTH to snap both, which is the default.

A SNAPped bitmap is initially invisible.

See also STAMP, SAVESNAP, LOADSNAP and SNAPSIZE.

SNAPSIZE

Outputs the size of a bitmap.

Syntax

Description

SNAPSIZE reports the size of a previously SNAPped bitmap shape as a list of two elements. The first element is the width of the bitmap in screen pixels and the second element is the height of the bitmap in screen pixels. See also SNAP, STAMP, LOADSNAP and SAVESNAP.

Example

SNAPSIZE 0 Result: [32 32]

STAMP

Draws a bitmap or turtle.

Syntax

Description

With no input, STAMP prints the shape of the active turtle(s) in the Graphics window with the turtle at the center of the image. Move the current turtle to see the stamped image. With one optional input, STAMP can stamp the specified turtle at the current turtle’s location.

The image stamp’s lower left corner is at the coordinates of the active turtle(s). If a width and height (in pixels) are also given as optional inputs, the image is stretched to occupy the specified area. The shape is stamped in its current scale and heading. See also SETSHAPE and SNAP.

Example

STAMP PU FD 40 PD

UNLOCKSHAPE

Lets a bitmap rotate according to the turtle’s heading.

Syntax

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.

Example

HOME SETH 45 LOCKSHAPE FD 100 UNLOCKSHAPE