CS21B Lab4: Graphics

Due 11:59pm Tuesday night, February 16

Run update21 to get the starting point files for this week's lab, which will appear in cs21/labs/04. The program handin21 will only submit files from this directory.

1. Drawing a face

Open the 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: Hello Kitty by Angela Meng and Charles Darwin by Elliot Padgett.

2. Drawing a Sailboat with mouse clicks

Open the file drawBoat.py and create a program that draws a sailboat in the graphics window. You should start with a blue rectangle at the bottom to represent the water. The location and size of the sailboat will be based on the user's mouse clicks as follows:

  1. The first two clicks will indicate the opposite corners of the rectangular body of the boat (called the hull). 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 top of the mast for the boat. The mast is the pole that holds up the sail. You should draw a narrow rectangle for the mast and a triangle for the sail. The three corners of the sail should be (a) the top of the mast, (b) the back of the boat just above the hull, (c) and the bottom of the mast just above the hull. See example images below.
  3. The fourth click will indicate the center of the sailor's head, and the fifth click will indicate the radius of her head. You should also draw in a body for the sailor.
  4. The sixth click should start some sort of animation, such as a cloud that moves across the sky or a fish that swims through the water.

Be sure to include a Text box at the top of the graphics window to explain each step to users of your program so that they know what each mouse click means.

Below are some examples of the output that might be produced by this program. Feel free to choose your own color scheme and to add more detail to the scene. Just be sure that your picture includes all of the required parts: text description, water, hull, mast, sail, sailor, and animation.


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