CS 154 Lab 6: Functional Graphics

We have gone over the functional approach to graphics (which is due to Conal Elliott) in lecture, specifically covering the simplified library I wrote to generate "bmp" bit-mapped graphic files from some simple primitive colors, shapes and transformations. In this lab, you will extend this library with some ideas of your own and then produce a picture which demonstrates the new features you came up with.

Graphics system files

You can get the files we worked with here:

You should be able to download both files to a common folder, then load up the RasterGraphics file and be ready to generate pictures. You will also need to change the file path used in the write function in the RenderBMP file, depending on whether you are using a Mac or PC, and to reflect your user name.

Once you have these files downloaded and loaded up into Hugs, you should be able to generate a file from a Figure by entering "try fig", where fig is the name of your Figure. (You may want to reduce the scale and magnification factors for speed while you work, then increase them again at the end for better-looking output.)


In your completed project, you should define and use at least the following:

  1. At least one new type of figure or pattern, i.e., something defined using basic mathematics which corresponds to a shape (such as a circle) or a pattern (like the spirals or checkerboards I defined). Figures will be of type Figure = Space -> Maybe Color.

  2. At least two new kinds of transformations defined using basic math, such as the shift, scale or skew transformations defined in my code. Transformations will generally be of type Figure -> Figure.

If you need help with ideas, or with the math needed to express them, you may look at the following pages for inspiration (these are the ones we looked at in lecture, just re-linked here):

Note, of course, that all work should be your own in the end: you may use these sources for ideas, but don't just snag something here and present it as your own work!