Concept
Using object oriented programming, I was able to create a piece of art which resembles everyday pressure and stress. Each circle, gets a randomly assigned color from the blue end of the spectrum. This is to symbolize the blues everyone faces every once in a while. Additionally, I wanted to implement something which takes away this pressure and so I did.
Code
This assignment was tricky to some extent as it was the first time I was facing OOP. However, by revising the class material and looking over online resources along with the p5js Reference, I was able to tackle it. I created a class for the circles and included four arguments in the constructor: x and y coordinates, radius and color. Then using a for loop, I created a program which assigns a random value to these arguments. This was done by this following code:
// Create 100 circles with random positions, sizes, and colors for (let i = 0; i < 100; i++) { let x = random(width); let y = random(height); let r = random(10, 15); let c = color(random(30), random(70), random(255)); let circle = new Circle(x, y, r, c); circles.push(circle); }
Additionally, as I wanted to add the option of clearing the canvas and resetting the animation, I wrote an if statement using some of the p5js built in functions. This allowed for the animation to be restarted just by pressing space bar. Following is the if statement I used:
function keyPressed() { if (key === "space") { circle.reset(); } }
Finally, I was left with the final version of my artwork which can be seen below:
Reflection
For this assignment, I felt like I was not able to fully express my creative thought as I was not familiar with the technical aspect of OOP. However, I am glad I was able to finish it and I am eager to learn more about the implications of OOP in generative art.