Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Turtle Shapes and Bitmaps

Load and save turtle shapes and bitmaps.

The commands in this group load and save turtle shapes and bitmaps. A turtle shape is a bitmap that can be loaded from a disk file, or a rectangular area of the graphics window.

LOADSHAPE

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

Syntax

Description

LOADSHAPE loads the specified image from the disk and sets the shape of all active turtles to that image. LOADSHAPE displays a File Open dialog if the input is a list of file type descriptors, or if LOADSHAPE is called without any inputs. For a description of file type descriptors, see the OPEN command.

If the file name is just a file name without any directory information, LOADSHAPE attempts to load the image from the Toolbox/Shapes folder if it cannot be found at the designated location.

If the loaded picture does not contain transparency information, you can use the shape’s TRANSPARENT property to define the color that should be transparent.

The turtle shape is always a black-and-white image with a size of 31×31 pixels. Any loaded image is scaled to such a black-and-white image.

See also LOADSNAP and SETSHAPE.

Example

The following example first looks for a Logo bitmap object named MOOSE. If it cannot find such a bitmap, it looks for MOOSE.PNG in the current directory; finally, it looks up MOOSE.PNG in the Shapes folder of the Toolbox and loads it from there.

LOADSHAPE “MOOSE SHAPE

LOADSNAP

Loads a bitmap.

Syntax

Description

LOADSNAP loads the specified file from the disk 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.

LOADSNAP sets the TRANSPARENT property of the loaded bitmap to white to make white pixels transparent. If you do not want this to happen, set the loaded bitmap’s TRANSPARENT property to an empty list to clear the transparency setting.

LOADSNAP displays a File Open dialog if it is called without any inputs, or if the input is a list of file type descriptors. For a description of file type descriptors, see the OPEN command. Clicking the Cancel button in a file open/save dialog causes the LOADSNAP command to return an empty list. See also SNAPSIZE and SAVESNAP.

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 a turtle shape.

Syntax

Description

SAVESHAPE saves the shape of the first active turtle or bitmap to disk. The shape is not saved in a rotated or scaled state. Turtle shapes are bitmaps with a transparent color so they can display as a non-rectangular shape.

SAVESHAPE displays a File Save dialog if it is called without any inputs, or if the input is a list of file type descriptors. For a description of file type descriptors, see the OPEN command. If you click the dialog’s Cancel button, SAVESHAPE returns without saving anything.

SAVESNAP

Saves a turtle shape.

Syntax

Description

SAVESNAP saves a turtle shape as a bitmap file directly on the disk. SAVESNAP saves graphics images in the format specified in the built-in variable :PICTURE.FORMAT unless a different file extension is given. You do not need to include the extension to save the file in the default format. These images can be loaded with LOADSNAP or LOADPIC.

SAVESNAP displays a File Save dialog if it is called without any inputs, or if the input is a list of file type descriptors. For a description of file type descriptors, see the OPEN command. If you click the dialog’s Cancel button, SAVESNAP returns without saving anything.

If any part of the bitmap image should be saved transparent, use the bitmap’s TRANSPARENT property to set the color(s) that should be treated as being transparent before calling SAVESNAP.

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.

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 SETSHAPE cannot find a turtle or bitmap with the given name, it calls LOADSHAPE to attempt to load the shape from a disk file.

If the picture does not contain transparency information, you can use the shape’s TRANSPARENT property to define the color that should be transparent.

The turtle shape is always a black-and-white image with a size of 31×31 pixels. Any bitmap is scaled to such a black-and-white image.

See also SHAPE, LOADSHAPE and LOADSNAP.

Example

Changes the shape of all active turtles to a moose.

SETSHAPE “MOOSE

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 window into a bitmap.

Syntax

Description

SNAP reports a region of the screen 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.

A SNAPped bitmap is initially invisible and attached to the same Graphics window as the first active turtle.

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: [31 31]

STAMP

Draw 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