Graphic JavaScript


Back to index
Resizing an Object

Your browser does not support the HTML5 canvas tag.

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:

  1. What is the purpose of the d variable?
  2. What happens to r when d is 0?
  3. What happens to r when d is 1?
  4. What are the possible values of d?
  5. 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.