Page 64 – Spirals

I have been studying JavaScript through books lately but I missed my 180 pages project! I wanted to do something inspired by the “rabbit” hole in my Code & Coffee talk. I haven’t played around with the HTML5 canvas for a while and definitely felt a little rusty!

To draw a spiral, you use the math formula for Archimedean spirals. In polar coordinates (r, theta), the locations of the spiral can be found using r = a + b(theta). The real numbers a and b control how the spiral acts and looks: b controls the distance between successive turns, a turns the spiral. If you increase a, the spiral turns clock-wise. To get the polar coordinates into cartesian coordinates, you use the sine and cosine functions. To get different shapes, I incremented the angle theta by different sizes. (It was fun going through all the possible shapes and picking some of my favourites!)

Aren’t these crazy? Look at the screenshot below… I promise it’s not moving!


Page 64 – Spirals


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s