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.
Loads a turtle shape from disk and sets the shape of all active turtles.
LOADSHAPE filename LOADSHAPE filename.ext LOADSHAPE type-descriptors (LOADSHAPE)
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
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.
The following example first looks for a Logo bitmap object named
MOOSE. If it cannot find such a bitmap, it looks for
the current directory; finally, it looks up
MOOSE.PNG in the Shapes
folder of the Toolbox and loads it from there.
LOADSHAPE “MOOSE SHAPE
Loads a bitmap.
LOADSNAP filename LOADSNAP filename.ext (LOADSNAP) LOADSNAP type-descriptors
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
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.
Prevents a bitmap from turning.
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.
HOME SETH 45 LOCKSHAPE FD 100 UNLOCKSHAPE
Saves a turtle shape.
SAVESHAPE filename SAVESHAPE filename.ext (SAVESHAPE) SAVESHAPE type-descriptors
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.
Saves a turtle shape.
SAVESNAP turtle filename SAVESNAP turtle filename.ext (SAVESNAP turtle) SAVESNAP turtle  SAVESNAP turtle type-descriptors
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
TRANSPARENT property to set the color(s) that should be
treated as being transparent before calling SAVESNAP.
Sets the shape of all active turtles.
SETSHAPE name-of-shape (SETSHAPE) SETSHAPE filename SETSHAPE filename.ext SETSHAPE type-descriptors
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
TRANSPARENT property to define the color that should be
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.
Changes the shape of all active turtles to a moose.
Outputs the name of the first active turtle’s shape.
Moves parts of the graphics window into a bitmap.
SNAP width height
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.
Outputs the size of a bitmap.
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.
SNAPSIZE 0 Result: [31 31]
Draw a bitmap or turtle.
STAMP (STAMP bitmap) (STAMP bitmap width height)
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.
STAMP PU FD 40 PD
Lets a bitmap rotate according to the turtle’s heading.
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.
HOME SETH 45 LOCKSHAPE FD 100 UNLOCKSHAPE