Using the Functional Graphics Teachpack with DrScheme

The fungraph.ss teachpack 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 five additional ones:

(write-image-as-epsf image filename)
This procedure writes the image out to an Encapsulated PostScript file with the given filename.
(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 default-image-size, which is a parameter that can be inspected or altered using the next two procedures. As described below, this is the same parameter that controls the size of the images created by line and filled-triangle.
(get-default-image-size) This returns the current value of default-image-size.
(set-default-image-size! new-value)
This changes the value of default-image-size to new-value.

The images produced by line and filled-triangle are of a size determined by the default-image-size. Initially this is 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 set 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
  (resize-image
   (filled-triangle 0 1 0 -1 1 -1)
   25))

The images produced by the procedures in this teachpack show up in the interaction window, the same way any other value would. On some systems, it is possible to copy and paste them within DrScheme. Where this is possible, you can then directly use them as input in other expressions. However, you can't use images from other sources in this way; for example, images inserted into DrScheme using the Edit menu's Insert Image... option are not usable as arguments to the procedures in the functional graphics teachpack.

As mentioned above, the images can only be copied and pasted within DrScheme on some systems. Further, they can't be saved out to files and loaded back in on any system. Both of these are symptoms of the same basic bug. We have an alternative implementation of the functional graphics package that works around this problem, but has some disadvantages of its own, described in its own web page.


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