CS21 Lab4: Graphics

Due 11:59pm Tuesday night, February 17

Run update21, if you haven't already, to create the cs21/labs/04. Then cd into your cs21/labs/04 directory and create the python programs for lab 4 in this directory (handin21 looks for your lab 4 assignments in your cs21/labs/04 directory):


$ update21
$ cd cs21/labs/04

$ pwd
  /home/your_user_name/cs21/labs/04

Your programs are graded on both correctness and style. Please review the comments regarding programming style on the main page.

Drawing a face

Open a file drawFace.py and create a program that draws a face using the graphics library. Here are some guidelines to follow:

Be creative! For inspiration, here are two example faces from previous cs21 students Madeleine Abromowitz and Jonathan Stafstrom.
Drawing a house with mouse clicks
Open a file drawHouse.py and create a program that draws a house with 5 mouse clicks as follows:
  1. The first two clicks will indicate the opposite corners of the rectangular frame of the house. The first click should be the lower left corner and the second click should be the upper right corner.
  2. The third click will indicate the center of the top edge of a rectangular door. The door should have a total width that is one fifth of the width of the house frame. The sides of the door should extend down to the bottom of the house frame.
  3. The fourth click will indicate the center of a square window. The window should be half as wide as the door.
  4. The fifth click will indicate the peak of the roof. The edges of the roof will extend from the point at the peak to the corners of the top edge of the house frame.
  5. Once you have completed the above requirements, add one of the following animated features to the scene: a cloud that drifts across the sky, a sun that rises or sets, or an animal or person that moves.
Be sure to include a Text box at the bottom of the graphics window where you can explain each step to the user of your program.

Below is an example of the output that might be produced by this program. Feel free to choose your own color scheme.

Submit

Once you are satisfied with your programs, hand them in by typing handin21 in a terminal window.