Objects and Arrays

Learning how to learn. I may have heard this phrase so many times for weeks now! The most painstaking part of learning p5 would probably be this week’s challenge of using objects and arrays together. Residents came back to me telling me that I should have everything in my toolbox to carry out this giphy I found:

Screen Shot 2017-10-17 at 11.17.21 PM

Of course I didn’t know where to start but with some help, I broke the ideas down into pseudocodes:

– Create a class called Circle

– Use methods that displays the circle and add steps to increase the size of the circle

– create an if statement to increase steps and for loops to multiple circles, then call the necessary functions.

After playing with some of those, I got my first set to line up. I’ve learned about creating variables, instances and realize that the loops needed an array to create more circles:

Let circleInstances = []; and then push new indexes to it. Then once I have figured out the proper spacing, I explored the colors using the map() function; Then once I’ve figured out the appropriate min-max radius size, I just duplicated the for loops and inverted the radius size increments.

My final code is posted here: http://alpha.editor.p5js.org/full/Sy0Xzif6-

Leave a comment