JS_Projects/20dots/dot.js

26 lines
591 B
JavaScript
Raw Permalink Normal View History

2022-11-09 23:34:49 +01:00
class Dot {
constructor(x, y, num, size) {
this.pos = new createVector(x, y);
this.x = x;
this.y = y;
this.n = num;
this.s = size;
this.ang = 0;
angleMode(DEGREES);
};
update(f) {
this.pos = new createVector(this.x, this.y)
this.pos.add(p5.Vector.fromAngle(radians(this.ang), this.s / 2 / 20 * (this.n + 1)));
this.ang += 360/144*(this.n + 1)/12;
}
show() {
push()
strokeWeight(6);
stroke(200, 50, 50);
point(this.pos.x, this.pos.y);
pop();
}
}