Functions & Modularity

Building upon a previous assignment and inspired by modularity, I updated the sketch to reflect the following:

  • separated the code into sections by creating my own functions for “sky” and “sun”. The sky function contains the code that allows the background to change color when mapped with the mouse (i.e.) transition from daylight to sunset. The sun function contains the code for drawing the sun.
  • I created a new function, star. I wanted stars to appear in the background when mouseX reached 400. The various stars are drawn by calling the function at different coordinates in the draw function.

Here’s the sketch!

 

Leave a Reply

Your email address will not be published.