next up previous
Next: Make a snowperson Up: Homework 4: Snowpeople! Previous: New stationery!

Use a bounding box

The arguments that draw receives (not including the graphic object) make up a bounding box. The bounding box specifies the invisible rectangle in which draw should draw.

1.
Inside draw, create a new bounding box that is the same height as the Slate but only one-third of the width, and centered. When I say ``create a bounding box'' I mean define four local variables that will contain the location and size. You are going to pass this bounding box as an argument to drawSnowperson.

2.
Create a new method named drawSnowperson that takes the same parameters as draw. To start, it should draw a single oval that fills the entire bounding box (in other words, it should have the same position and location as the bounding box).

3.
Change the size of the Slate and run your program again. The size and proportion of the oval should adjust so that, no matter what the size the Slate is, the oval is the same height, one-third of the width, and centered.



Allen B. Downey
1999-09-29