For your homework this week you can either;
My example below demonstrates the work we did this week in class, by creating a complex, generative smiley face example.
setup()
or draw()
).As always, you should comment your code, write a readme, and provide links on the HW forum to both your git repo, and live sketch.
For this week’s example, I do a number of things. However, the main goal was to create a sketch with smiley faces that rotate on the x
and y
axis according to a sinusoidal function. This sine function determines not only relative position, but also the scale factor of the smiley face.
As you can see from the code;
smileys
), to store objects holding data about each smiley.t
to track the progression of time.drawSmiley()
accepts a smiley object as its input. It then calls the sine function to determine position on both the x
and y
axis, and also calls the function to actually draw each smiley (smileyFace()
).smileyFace()
function is the same one you saw earlier this week.sinePos()
function determines a position value based on the movement of time (time
) and the timeScale
of each individual smiley object.draw()
function, the array of smileys is worked through and used to draw smiley faces in orbit.mouseX
position between 0
and the length
of the smiley array. Thereby, allowing the user to determine how many orbiting smileys that see.[ Code Download ] | [ View on GitHub ] | [ Live Example ] |