p5js: Functions

This week, I wanted to consolidate the code of the project I worked on with Dawn for week 3’s assignment of algorithmic design.

giphy1.gif

Quite frankly, the code itself is pretty simple and already makes use of inherent functions, specifically createSlider(). I made an attempt to create a function that would encapsulate the naming of the slider, assigning the min, max, value, step within the createSlider(), and assigning the slider’s position. I broke a few things in the process, and ultimately concluded that creating a function to use a function felt redundant.

p5jsW5.PNG
p5jsW52.PNG

I created a function specifically for the GUI’s sections. This simplified creating the color of the rectangle, positioning the rectangle, adding the title, and positioning the title.

p5jsW53.PNG