Concept
This work creates art from outward spirals employing the concept of classes and arrays. The spirals are created at the position of the mouse when it is clicked. The spiral get assigned a random color and it has a translucent effect to help blend colors and create a more visually pleasing effect. The blur function was also used to make the work more fluid.
Code I’m proud of
function mouseClicked() {
let newBall = new Ball(mouseX, mouseY, random(20, 100), random(-5,5), random(-10,10));
balls.push(newBall);
// Prevents program from slowing down
if (balls.length > 25) {
balls.shift();
}
}
This is the code that creates the spirals. It makes a new spiral when the mouse is clicked and then adds it to an array. I noticed that the program was glitching as the number of spirals increased. I then added a code to remove the oldest spiral created when the number of spirals reached 25. This kept the code running smoothly.
Code
Click to start
Press the space bar to clear the screen
Reflection
This exercise helped me put to practice my knowledge in classes and arrays while also using previous knowledge acquired throughout the course. It was really fun creating this work. This program can be improved by adding more features to the spirals through the class to create more visual effects.