PSICS Fall 2004 - HW#2

HW#1: Functions and Programs that draw pictures


This assignment involves writing scheme code to draw pictures (or perhaps to create "works of art"?). In the first part of the assignment you need to come up with the design and implementation for two graphic-drawing functions and publish some documentation (and implementation) about these functions to the rest of the class. In the second part of the assignment you are to create a "work of art" by writing a program that uses the functions provided by yourself and other people in the class.

Part 1: Design and implement two picture-drawing functions

You should make use of the primitive graphic operations supported by the teachpack draw.ss which are described here.

You design and implement at least two of your own graphic-drawing functions. For example, you could design a function that draws a house given a starting point and some kind of size. Using the funciton might look like this (start at 100,100; size is 80):

(draw-house (make-posn 100 100) 80)

Note that you alone determine what values the function consumes! You will write some documentation along with your function - your documentation will provide others with enough information so that they can use your function. It is important that your functions always evaluate to the value true (so they can be called many times inside an AND expression)

Here is an example of what is expected for the documentation, I'm calling my function draw-snowman:

;; draw-snowman consumes a posn, a number and a color (symbol)
;;
;; (draw-snowman position size color)
;;  will draw a snowman starting at the x,y coordinates specified
;;    by the posn structure position, with a size specified by size
;;    as the radius of the bottom of the snowman (bottom circle)
;;
;;    note that the position is used as the center of the bottom 
;;    circle of the snowman.
;;    
;; sample usage:
;; (draw-snowman (make-posn 100 200) 50 'red)
;; (draw-snowman (make-posn 200 200) 20 'blue)
;; 
;; note that this requires the teachpack draw.ss and requires that the
;; start function has already been called to create a window.
;;

The general idea is that someone else could decide to create a drawing with a buch of snowmen, and write the following function:

(define (drawfamily base-position color)
  (and
     (draw-snowman base-position 50 color)
     (draw-snowman 
	     (make-posn 
		    (- (posn-x base-position) 100) 
            (posn-y base-position))
		  20 color)
     (draw-snowman 
	     (make-posn 
		    (+ (posn-x base-position) 100) 
            (posn-y base-position))
		  20 color)))

Calling this function in the following program could produce something like the picture shown below.

(start 300 300)
(draw-family (make-posn 150 200) 'red)

You can get the complete code for the above example here: snowman code

You will submit your documented code to Dave, who will then post the code on the web so everyone can use your drawing functions.

Part 2: Create a work of art using your functions and at least 3 from other people

You can write any functions you want (like my draw-family above), or just write a program that calls the functions you want.

There may (or may not) be prizes for the best artwork!

Submission

Submit your functions by 11:59 PM, Friday, Sept 17th by sending them as email to Dave (hollingd@cs.rpi.edu). Dave will organize these and post the code on the course home page

Artwork is due by email (once again to hollingd@cs.rpi.edu) by 11:59PM Tuesday, Sept 21st. If you get something done sooner, bring the code to class next Monday so we can all see your artwork!