The Graphics canvas
The Graphics canvas is the drawing surface for the turtles. It is 2000 by 2000 pixels wide, but Logo only displays a small portion of it through its Graphics panel. The Graphics panel is the viewport, whose size varies depending on the size of the browser canvas or the position of the splitter that separates the Graphics panel from other panelsl. The SETBOUNDS command can be used to set the size of the viewport to a fixed value.
BOUNCE
Lets the turtles bounce off the graphics bounds inside the Graphics panel.
Syntax
BOUNCE
Description
BOUNCE maintains the turtle inside the drawing bounds of the Graphics panel (see SETBOUNDS) no matter how large a movement command is given. Any time the turtle moves off the bounds, it bounces off the bound. When Logo starts up, the default state is WRAP. See also WRAP, FENCE and WINDOW.
Note that you can set each turtle’s wrap mode individually by setting its WRAPMODE property to something else than the initial DEFAULT value, which makes the turtle use the Graphics panel’s wrap mode.
Examples
HOME SETBOUNDS 100 SETH 20 BOUNCE FD 500
BOUNDS
Reports the drawing bounds of the Graphics panel.
Syntax
BOUNDS
Description
BOUNDS reports the drawing bounds of the Graphics panel as a two-element list, which is the maximum value of the X and Y directions that a turtle can move. The bounds is the number of pixels a turtle can travel in either direction before it wraps in WRAP or BOUNCE modes, or stops in FENCE mode. A value of 200, for example, limits the turtle movements to the coordinates -200 and 200 in either direction. When Logo starts up, the bounds are set to follow the size of the viewport.
See also SETBOUNDS, WRAP, BOUNCE, and FENCE.
Examples
BOUNDS Result: [680 450]
CLEAN
Erases the Graphics panel and homes the turtle.
Syntax
CLEAN
Description
CLEAN erases the Graphics panel but does not affect the heading or position of the turtle. See also CLEARSCREEN and DRAW.
Examples
HOME SETPC “RED SETH 20 FD 50 CLEAN FD 50
CLEARSCREEN
Also: CS
Erases the Graphics panel and homes the turtle.
Syntax
CLEARSCREEN
Description
CLEARSCREEN erases the Graphics panel, returns the turtle to the center of the panel, and sets the turtle’s heading to 0. CLEARSCREEN does not affect the pen state or panel colors. See also CLEAN and DRAW.
Examples
HOME SETPC “RED SETH 20 FD 50 CLEARSCREEN FD 50
DRAW
Clears the Graphics panel and resets all turtles.
Syntax
DRAW
Description
DRAW prepares the Graphics panel for drawing by doing the following:
-
Clears the panel.
-
Resets the panel bounds to follow the viewport.
-
Erases all images and controls.
-
Resets all turtles to their default values.
-
Sets turtle 0 to be the active turtle
-
Homes the turtle.
-
Shows the turtle.
-
Puts the pen down.
See also CLEARSCREEN and CLEAN.
Examples
TELL 0 HOME RT 22 FD 10000 DRAW
FENCE
Fences all turtles inside the drawing bounds.
Syntax
FENCE
Description
FENCE prevents the turtle from moving beyond the edge of the Graphics drawing bounds (see SETBOUNDS). If you try to move the turtle outside the bounds, it moves to the drawing bound and stops. See also WRAP, BOUNCE, and WINDOW.
Note that you can set each turtle’s wrap mode individually by setting its WRAPMODE property to something else than the initial DEFAULT value, which makes the turtle use the Graphics panel’s wrap mode.
Examples
HOME SETH 20 FENCE FD 1000
FREEZEPIC
Freezes the display of the Graphics panel.
Syntax
FREEZEPIC
Description
FREEZEPIC freezes the display of the current drawing. All drawings made after FREEZEPIC will not alter the drawing on screen, but will be executed in memory.
FREEZEPIC is useful if you want to create a drawing without the user noticing. Use FREEZEPIC to stop the display, then draw your picture, and finally use UNFREEZEPIC to make the drawing appear immediately.
A good example is the creation of a shape. Use FREEZEPIC on an empty screen to start drawing; then, create the shape and attach it to the turtle with a combination of the SNAP and SETSHAPE commands.
See also UNFREEZEPIC.
Examples
; Create a golden block and use that block as the turtle shape. DRAW FREEZEPIC SETPC “GOLD (STAMPRECT 20 20 TRUE) SETSHAPE (SNAP 20 20 “DRAWING) CLEAN UNFREEZEPIC
LOADPIC
Loads a picture.
Syntax
LOADPIC filename.ext
(LOADPIC filename.ext TRUE)
LOADPIC [extensions-list]
(LOADPIC [extensions-list] TRUE)
(LOADPIC filename TRUE/FALSE mode)
(LOADPIC)
Description
LOADPIC loads the file into the Graphics panel. The file is loaded as a bit map that fills the current viewport. If no extension is given to the filename, the picture format that is loaded is the format specified in the global variable :PICTURE.FORMAT. If the file has a different extension, then the extension must be specified in the LOADPIC command.
If the second input to LOADPIC is TRUE, LOADPIC loads multiple copies of the image instead and fills the entire graphics screen with these copies (it tiles the images).
If you use a list of file extensions as the file name, or use the command without inputs, Logo displays a dialog that lets you select a file name.
If loaded as a background image, the loaded picture is behind any background color; if the background color is non-transparent, it hides the background image. For example, if you use the command SETBG “GOLD, the background turns into gold, and any background image is hidden. If you set a background pattern, the pattern hides the background image only partially, allowing the background image to “shine through”. This is especially true if you use a color with a lower alpha value, making the color transparent. If you, for example, use the command SETBG [0 255 0 0.2], the background color changes to a transparent green, making the background image appear greenish.
The optional third input is either “BACKGROUND to load the image as a background image (which is the default), or “DRAWING to load the image as a drawing.
The combination of background images, background patterns and partially transparent background colors allows for a lot of interesting and fun color effects.
SAVEPIC
Saves the contents of the Graphics panel.
Syntax
SAVEPIC filename.ext
SAVEPIC [extensions-list]
(SAVEPIC filename mode)
(SAVEPIC filename mode TRUE)
(SAVEPIC)
Description
SAVEPIC saves the contents of the Graphics panel into a bitmap file in a data space. SAVEPIC uses the boundaries of the Graphics panel. SAVEPIC saves its files in PNG or JPG format depending on the setting of the PREFS property PICTURE.FORMAT.
If you use the command without inputs, Logo displays a dialog that lets you select a file name.
The optional second input is either “BACKGROUND to save the background only, “DRAWING to save the drawing only, or “BOTH to save both, which is the default.
If a third input is present and is TRUE, Logo downloads the file to the Downloads folder without asking for permission.
If the PREFS property PRINT.BITMAPS is TRUE, SAVEPIC also saves all turtles, bitmaps and controls as well.
Examples
SAVEPIC “Sample
SETBOUNDS
Set the drawing bounds of the Graphics panel.
Syntax
SETBOUNDS size
SETBOUNDS [x y]
(SETBOUNDS)
Description
SETBOUNDS sets the drawing bounds of the Graphics panel. The bounds is the number of pixels a turtle can travel in either direction before it wraps in WRAP mode, bounces in BOUNCE mode, or stops in FENCE mode. A value of 200, for example, limits the turtle movements to the coordinates -200 and 200 in either direction. When Logo starts up, the bounds follow the size of the viewport.
If SETBOUNDS is called with a two-element list, the list is used to set separate values in X and Y directions. If SETBOUNDS is called without inputs, the bounds are reset to follow the viewport.
See also BOUNDS, WRAP, BOUNCE, and FENCE.
Examples
HOME
SETBOUNDS 60
SETH 20
BOUNCE
FD 800
SNAP
Moves parts of the Graphics panel into a bitmap.
Syntax
SNAP width height
(SNAP width height mode)
Description
SNAP records a region of the Graphics panel and creates a new bitmap of that region. 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.
SNAP reports the name of the newly created bitmap. Use ASK or TELL to access the bitmap. A SNAPped bitmap is initially invisible.
See also STAMP, SAVESNAP, LOADSNAP and SNAPSIZE.
Examples
DRAW
; draw a rectangle and SNAP it
SETPC 4 (STAMPRECT 50 50 TRUE)
SNAP 50 50
Result: BITMAP
; talk to the bitmap instead of a turtle
HT CLEAN
TELL “BITMAP
ST
; STAMP it a few times
REPEAT 8 [FD 60 RT 45 STAMP]
SNAPSIZE
Outputs the size of a bitmap.
Syntax
SNAPSIZE turtle
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.
Examples
SNAPSIZE 0 Result: [32 32]
STAMP
Draws a bitmap or turtle.
Syntax
STAMP
(STAMP bitmap)
(STAMP bitmap widthAndHeight)
(STAMP bitmap width height)
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. If only a single number is provided, STAMP uses that value for both width and height.
The shape is stamped in its current scale and heading. See also SETSHAPE and SNAP.
Examples
STAMP PU FD 40 PD
UNFREEZEPIC
Unfreezes the display of the graphics.
Syntax
UNFREEZEPIC
Description
UNFREEZEPIC undoes the FREEZEPIC command. It updates the display with the drawing made while the graphics display is frozen, and resumes normal drawing mode, where all drawings immediately appear on the display.
See also FREEZEPIC.
Examples
; Create a golden block and use that block as the turtle shape. DRAW FREEZEPIC SETPC “GOLD (STAMPRECT 20 20 TRUE) SETSHAPE (SNAP 20 20 “DRAWING) CLEAN UNFREEZEPIC
WINDOW
Removes the boundary for turtle movements.
Syntax
WINDOW
Description
WINDOW removes the boundaries from the turtle’s field of movement. If the turtle moves beyond the Graphics drawing bounds, it continues to move, but cannot be seen if it leaves the visible portion of the Graphics panel. The Graphics panel becomes a small canvas overlooking the plane on which the turtle can travel.
See also BOUNCE, FENCE and WRAP.
Note that you can set each turtle’s wrap mode individually by setting its WRAPMODE property to something else than the initial DEFAULT value, which makes the turtle use the Graphics panel’s wrap mode.
Examples
HOME SETH 20 WINDOW FD 1500
WRAP
Lets the turtles wrap inside the Graphics panel.
Syntax
WRAP
Description
WRAP maintains the turtle inside the Graphics drawing bounds (see SETBOUNDS) no matter how large a movement command is given. Any time the turtle moves off the panel bounds, it wraps around the panel and reappears on the opposite edge. When Logo starts up, the default panel state is WRAP.
See also BOUNCE, FENCE and WINDOW.
Note that you can set each turtle’s wrap mode individually by setting its WRAPMODE property to something else than the initial DEFAULT value, which makes the turtle use the Graphics panel’s wrap mode.
Examples
HOME SETH 20 WRAP FD 1500
GRID
Sets the characteristics of the graphics grid.
Syntax
GRID size
GRID [x-size x-size]
(GRID size display-units)
(GRID size [x-display-units y-display-units])
(GRID size FALSE)
Description
GRID sets the horizontal and vertical characteristics of the Graphics panel grid to its inputs. The first input is either a number, or, if different values are desired for the horizontal and vertical size, a two-element list with the horizontal and vertical grid size. The input values are between 20 and 1000.
The second input is optional. If the input is FALSE, the grid does not display any coordinate values. If it is a number, the grid displays multiples of the given value as horizontal and vertical coordinates. If it is a two-element list, the list contains numbers for the horizontal and vertical coordinates.
Examples
GRIDON WAIT 1000 ; show a grid with a size of 80 and values as multiples of 10 horizontal and 5 vertical (GRID 80 [10 5]) WAIT 1000 ; show a grid with 100 horizontal and 50 vertical units, no coordinates (GRID [100 50] FALSE)
GRIDOFF
Hides the grid of the Graphics panel.
Syntax
GRIDOFF
Description
GRIDOFF hides the grid in the Graphics panel.
Examples
GRIDON WAIT 1000 GRIDOFF
GRIDON
Displays the grid of the Graphics panel.
Syntax
GRIDON
(GRIDON size)
(GRIDON [horizontal-size vertical-size])
Description
GRIDON displays a grid in the Graphics panel. By default, the size of the grid is 100 pixels on each axis.
The size of the grid may be changed by supplying GRIDON with a list containing the desired horizontal and vertical scales for the grid and putting GRIDON and its argument in parentheses. The permitted value range is between 20 and 1000. Use the GRID command for more display options.
See also GRIDOFF.
Examples
(GRIDON [150 50])
WAIT 1000
GRIDON