HW2: Algorithms for Drawing, Revisited


Due: 9 a.m. Wednesday, 28 January 2009

Summary: In this assignment, you will extend your ideas from the introductory lab on writing algorithms and the lab creating drawing instructions for GIMP.

Purposes: To give you more experience thinking about writing algorithms. To give you the opportunity to identify parts of an algorithm.

Expected Time: Two to three hours.

Collaboration: I would prefer that you work in groups of size three. However, you may work alone, in a group of size two, or a group of size four. You may discuss this assignment and possible solutions with anyone you wish. If you discuss this assignment with people other than group members, make sure to include a citation (e.g., “I consulted this person, who helped me do this”).

Submitting: Send your answer to . The title of your email should have the form CSC-151-01 HW2 and should contain your answers to all parts of the assignment. I prefer that you put your answers in the body of the message, rather than as an attachment.

Notice: So that this assignment is a learning experience for everyone, I may spend class time publicly critiquing your work.

Background

In the first laboratory for this course, we asked various groups to consider mechanisms for drawing smiley faces. We'll also soon be learning another way to describe and create images: GIMP Tools. In the lab introducing the GIMP, you had to write down instructions for creating a smiley face image in GIMP.

What kinds of things might one consider in assessing the various solutions? One might reflect on the correctness and complexity of each algorithm. One might look at the use of various algorithm components (repetition, conditionals, naming, subroutines, etc.) One might compare the different core operations. One might also look at the quality of the result that is produced. Finally, one might consider how easy it is to understand the algorithm.

Assignment

Part One: Describing a Drawing

Your first task is to give an algorithm (in English) for creating a drawing of some recognizable object or scene. The choice of subject is up to you. However, you are limited to the following “operations” in creating your drawing:

  • Select a specified brush.
  • Select a new foreground or background color.
  • Select an ellipse or rectangle of a given size and location.
  • Fill or stroke the selection.
  • Select nothing. (That is, de-select everything.)
  • Draw a line between two points.

Your drawing algorithm should use at least 20 such operations.

Part Two: Giving GIMP Instructions

In Monday's lab, you will learn how to give the GIMP precise instructions in MediaScheme to create drawings using operations much like the ones described above. Translate your algorithm above into precise commands using the GIMP tools for Scheme.

To help keep us oriented, please place comments in your code to explain at a higher level what the instructions do. Any line that begins with a semicolon is ignored by the Scheme interpreter, but can be read by humans as a comment. For example, you might precede sections of code with comments such as the following:

; Draw a red square
(context-set-fgcolor! "red")
... 

or even

; Draw the left eye
(image-select-ellipse! ...)
... 

Part Three: Reflecting on Changes

Did you have to modify your algorithm at all to actually create your image using GIMP? If so, describe what things needed to be changed. If not, what about your approach to part one made it possible to move to part two with ease?

Important Evaluation Criteria

The first criterion we will use in evaluating your assignments is correctness - is each set of instructions likely to produce the desired image?

The second criterion we will use in evaluating your assignments is clarity - how easy is it to understand your instructions and your intentions?

The third criterion we will consider is creativity. We will consider whether you have used innovative or particularly interesting techniques to create a drawing.


Jerod Weinman