xxxxxxxxxx
23
/*
My current sketch draws a repeatedly growing and shrinking ellipse. Help me change the program so that this behavior is encapsulated inside a class. Move all this behavior to a class, then have mouse clicks create instances of the class on the screen. Use a JavaScript push() to store the instances of the class that you create, and update and display all of them in the draw() loop.
*/
let x = 300;
let y = 300;
let d = 0;
let incr = 2;
let maxSize = 150;
function setup() {
createCanvas(600, 600);
}
function draw() {
background(150);
ellipse(x, y, d, d);
if (d > maxSize || d < 0) {
incr = -incr;
}
d += incr;
}