# Using the Functional Graphics Library with EdScheme for the Macintosh

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`.

## Making images appear

Contrary to the book, images are not automatically displayed. For example, you can not simply evaluate `(line -1 -1 1 1)` to see a diagonal line appear on your screen. Instead, you have to explicitly apply the `draw` procedure to the image, as in `(draw (line -1 -1 1 1))`. Note that this wrapping of `draw` around images should only be done for top-level evaluations typed in by the user, not internally to procedures that operate on images. For example, in Chapter 1's application section, you might do `(draw (pinwheel rcross-bb))` to see what a pinwheeled rcross-bb looks like, but you wouldn't use `draw` anywhere in `pinwheel`. `Pinwheel` still constructs an image just as in the book; the only difference is that you now need to make that resulting image appear on the screen by using `draw`.

## Extensions

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

`(draw `image`)`
This is described above.
`(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. The unit of measure is the "turtle step" defined by EdScheme.
`(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 60. This is a compromise size, rather small for the fractals in chapter 4 and a bit 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. Or, as a final option, you can specify a size as an additional argument to the basic image construction procedures, as in the following example:

```(filled-triangle 0 1 0 -1 1 -1 25)
```
You can specify a size in this way with `line` as well as `filled-triangle`, and can also specify two values, for width and height, as with `resize-image`.

The `overlay` and `stack` procedures are not restricted to two arguments, but rather can take one or more.

For more information, see the parent web page, or contact Max Hailperin:
Email: max@gustavus.edu
Mathematics and Computer Science Department