Resizing an Object
|
ASSIGNMENT:
Click on the canvas area several times to discover what behavior is produced
by clicking. Inspect the code carefully. Be able to answer these questions:
- What is the purpose of the d variable?
- What happens to r when d is 0?
- What happens to r when d is 1?
- What are the possible values of d?
- What are the possible values of r?
Redesign the applet so that a pentagon grows and shrinks. Allow it to shrink
to a radius of 5 and to grow to a radius of 80. Set a starting value of r=40
and d=2. Set growth increments to eight and shrinking decrements to five. Also have the pentagon change
colors after every click. Supply at least six color values to support this
behavior.
|