Intro to Computational Media

Week 5: Snowfall

This week I experimented with classes in javaScript.  To do this I created a snowfall scene with unique snowflake instances.  First, I made one snowflake using a rotate and repeat method around its center (Figure 1). 

Figure 1 : First snowflake

Figure 1: First snowflake

I placed this snowflake into a class and created two snowflake instances.  Adjusting different elements of the snowflake class changes the look of the individual snowflakes (Figure 2).

Figure 2 : Adjusting snowflake parameters

Figure 2: Adjusting snowflake parameters

Next I created a move() function within the snowflake class to animate the two snowflakes (Figure 3).  When the snowflakes move just past the height of the screen, they move back to the top and repeat the falling motion.  This creates the look of a continuous snowfall.

Figure 3: Two snowflakes falling

In the end, I created an array of many unique snowflakes and displayed them falling at different rates (Figure 4).  The final result can be viewed at this link.  I had some trouble trying to get each individual snowflake to rotate about its own center as it fell.  If I were to continue this project I would work on solving that problem and add more variation to the look of each snowflake. 

Figure 4: Snowfall

Once I completed this project, I used serial input to connect this animation to an Arduino for my Pcomp homework. I adjusted the sparkle of each snowflake using the location of a potentiometer. Figures 5&6 show the results.

Figure 5

Figure 6

Eva PhilipsComment