Homework 2: Like a Spiral in a Circle

Short Description:

Write a program that creates a crude spiral in a canvas.


When you finish this homework, you should

Formal Description

Write a program that will draw a spiral in the html canvas.

You should present the user with a simple interface which contains

An example might be

Your program should initially resize the canvas to the default values stored in the input boxes (100,100) and draw a spiral.

When the user changes the input and presses the redraw button, you should, if this input is acceptable, adjust the size of the canvas and redraw the spiral.

The canvas may be no smaller than 50x50 and the space must be at least 3. The space must be less than the 1/2 of width or height of the box, whichever is smaller.

If inappropriate values are input, the program should catch these, refuse to change, and replace the values in the input box with the previous values.

To draw a spiral, start at (size, size) and draw a line to (canvas.width-size, size). Then draw a line from (canvas.width-size, canvas.height-size). Repeat this process, decrementing or incrementing the starting and ending points appropriately to draw a spiral. The process should end when there is no way to draw a line that would not intercept the figure.


Please use relative references to your code in the html file. This will allow me to extract the file in my local environment.

Additional Requirements/Comments


I find that I want to continue to play with simulations/visualizations of this type. Please do so, but only if you have sufficient time, do not enhance this, or any other project at the expense of your other classes.


When you have finished your assignment, please submit a tar or zip file containing all files needed for this project. Please do not post your project on line until after grades have been assigned.

Submit your file to the D2L homework folder Homework 2 by the due date.