Using the Functional Graphics Library with MIT-Scheme

The fungraph.scm library provides the procedures for producing graphical images described in Concrete Abstractions. Because these procedures operate like mathematical functions, we refer to them as functional graphics, hence the name fungraph.

In addition to the procedures described in the textbook, there are three additional ones:

(close-image image)
This removes from the screen the window (if any) containing the image. If the image is later displayed again, a new window will be created, once again containing the image. Note that "manually" closing the window using the mouse doesn't have the same effect; no new window will be created for the image unless close-image is used.
(mirror-image image)
Like quarter-turn-right or invert, this takes an image and makes another, related image. In the case of mirror-image, the new image is the same size as the original, and is formed by flipping the original image around a vertical axis, as though it were viewed in a mirror.
(resize-image image width height)
This makes a new image similar to the original, but stretched or shrunk as necessary to have the specified width and height. This may also imply a change in the image's proportions. The width and height must both be exact, positive integers.
(resize-image image size)
This is a shorthand, equivalent to (resize-image image size size), i.e., the specified size is used as both the width and the height of the new image.
(resize-image image)
This is a further shorthand, equivalent to (resize-image image default-image-size default-image-size), i.e., the width and height are both taken as the value of default-image-size. As described below, this is the same name that controls the size of the images created by line and filled-triangle.

The images produced by line and filled-triangle are of a size determined by the value of the name default-image-size. Initially this name is defined as 100. This is a compromise size, a bit small for the fractals in chapter 4 and rather large for each basic block of the quilts in chapters 1-3. You can redefine it to another value (which must be an exact, positive integer) to suit your own needs. Or, you can use the resize-image procedure described above. For example, when defining the basic blocks for quilting, it may make sense to do so as in the following example:

(define test-bb
   (filled-triangle 0 1 0 -1 1 -1)

The images produced by the procedures in this library show up in separate windows, with numerical titles. The number used for the title on the window is the so-called hash code, which is also displayed in the textual representation of the image. For example, you might see #[image 2 100x100] as the textual representation of an image, in which case the image will be shown in the window with the title 2. (The 100x100 indicates the image's width and height.) You can later refer to this image as #@2, which is a special MIT-Scheme syntax for the object with hash code 2 (which can be anything, not just an image). However, if the image is garbage collected (i.e., the memory used for it is reclaimed for other purposes), then the window will vanish and #@2 will no longer be usable.

For more information, see the parent web page, or contact Max Hailperin:
Mathematics and Computer Science Department
Gustavus Adolphus College
800 W. College Avenue
St. Peter, MN 56082