JS_Projects/20dots/animation.js
Dawid Pietrykowski 25a12f221e Initial commit
2022-11-09 23:34:49 +01:00

38 lines
881 B
JavaScript
Executable File

class Animation {
constructor(x, y, size) {
this.pos = new createVector(x, y);
this.x = x;
this.y = y;
this.size = size;
this.dots = [];
for (let i = 0; i < 20; i++) {
this.dots.push(new Dot(this.x, this.y, i, this.size));
}
};
update(f) {
for (let i = 0; i < 20; i++) {
this.dots[i].update(f);
}
}
show() {
for (let i = 0; i < 20; i++) {
noFill();
stroke(230);
strokeWeight(2);
circle(this.x, this.y, this.size / 20 * (i + 1));
this.dots[i].show();
}
push();
stroke(55);
strokeWeight(3);
beginShape();
for (let i = 0; i < 20; i++) {
vertex(this.dots[i].pos.x, this.dots[i].pos.y);
}
endShape();
pop();
}
}