Problem Set 2 - Due Tue, Sep 18 at 23:59

Reading

  1. Goldwasser & Letscher, Chapter 3, sections 3.3-3.6, pages 103-110.
  2. Slides and notebooks from Lec 3.
  3. Problems and solutions from Lab 2.

About this Problem Set

Other notes:


Task 1: Debugging Graphics

This is an individual problem which you must complete on your own, though you may ask for help from the CS111 staff.

As part of experimenting with layers and transformations in cs1graphics, Lois Reasoner wishes to create the following picture, which contains 4 transformed versions of a face:


Relative to the upper left face:

Lois writes a program in an attempt to create the above picture. Click here for Lois's program, a copy of which can be found in the ps02 folder as debugGraphicsBuggy.py. Although it is structured well and in many ways is close to correct, Lois's program generates the following incorrect picture due to numerous bugs:


Your goal in this subtask is to fix Lois's program so that it generates the correct picture. In the ps02 folder is a file debugGraphicsFixed.py that is initially a copy of Lois's buggy debugGraphicsBuggy.py program with some extra header information at the top that you should fill out and an extra triple-quoted comment section at the bottom (more on this below). You should modify debugGraphicsFixed.py by finding and fixing all the bugs it contains, so that it ultimately generates the correct picture.

Notes:


Task 2: Bunny Money Pattern

This task is required but you have the option to work with a partner on it if you wish. We strongly encourage you to work in pairs on this problem. Use this shared Google Doc to find a pair programming partner and record pair programming partnership.

Your goal in this task is to generate the following picture by fleshing out the file bunnyMoneyMosaic.py in the ps02 folder:


There is a lot of stuff going on in this picture. You can see that one pattern is repeated, at different sizes and rotations. Let's call this pattern bunnyMoney, as shown below (enlarged):

The bunnyMoneyMosaic.py file begins by importing the following shapes to get you started; the rest you will create using cs1graphics.

Two graphics objects that are provided for you:

Description Graphic
bunny
This is a layer that is returned by calling the
makeBunny function imported from bunny.py.
Its reference point is marked by an orange circle.
wedge
This is an orange polygon that is returned by calling the
makeWedge function imported from from wedge.py
Its reference point is in its upper left corner.

In general, we recommend that you start with pencil and paper (as opposed to jumping into Canopy). You want to build your code incrementally, making sure that smaller parts work before attempting the entire picture.

Useful bunnyMoney information:

  1. The large green (lightgreen) rectangle has a width of 600 and height of 300
  2. The blue (navy) circle in the center of the bunnyMoney has a radius of 75
  3. Each of the small wedges + bunny on the navy circle are one-quarter the size of the original wedge + bunny
  4. The grey (darkgrey) rectangle has a width of 330 and height of 70
  5. This set of slides give a high-level overview of how to make bunny money.
  6. Here is bunnyMoney shown with a gridlines spaced 50 apart and also with gridlines spaced 25 apart (use the grids to figure out where to place things):

Bunny Money Mosaic information that will be useful for you:

  1. The pink canvas has dimensions 900x600
  2. The 900x600 bunny money mosaic with grid is shown here:
  3. Note that the ears of the bunny are always outlined in white; sometimes the bunny is scaled smaller and the ears may appear to be non-white, but rest assured they retain their original color.

Notes



Task 3: Fancy Bunny Money [THIS IS AN OPTIONAL TASK]

If you had fun making bunny money and have time to spare, then you can complete this OPTIONAL task. In this OPTIONAL task, the goal is to create this picture in the file fancyBunnyMoneyMosaic.py:

The image is very similar to the one in Task 2 above, but has a line of bunnies in the grey rectangle.

Useful fancy bunny money tips:

  1. Here is an enlarged view of fancy bunny money with a grid (each grid line is 50 units apart):
  2. The smaller bunnies are 30% the size of the original bunny; the larger bunnies are 42% the original size.
  3. Here is an enlarged closeup of the line of bunnies with a grid (each grid line is 10 units apart):
    .
    This gives information about where to place each bunny.

Task 4: Honor Code Form

The ps02 folder contains a file honorcode.py with several variable assignments for your name, the time you spent on the tasks, etc. Change the values in these variable assignments to appropriate values.

How to turn in this Problem Set

Softcopy (electronic) submission:

Hardcopy (paper) submission

There is no hardcopy submission. Problem set submission is entirely electronic.