xxxxxxxxxx
39
class Circle {
constructor(hue, s, b, rad) {
this.r = rad;
this.h = hue;
this.a1 = 0;
this.a2 = 0;
this.c = color(hue, s, b-50);
this.cc = color(hue, s, b);
this.p = createVector(random(this.r/2, this.width-this.r/2), random(this.r/2, this.height-this.r/2));
this.e = createVector(random(this.r/2, this.width-this.r/2), random(this.r/2, this.height-this.r/2));
this.di = createVector();
this.s = 0;
this.d = this.p.dist(this.e);
this.sW = random(1, 4);
}
update() {
this.s = 5-3*cos(map(this.p.dist(this.e), this.d, 0, 0, 360));
this.a1 = map(this.s, 2, 22, 0, 100);
this.a2 = map(this.s, 2, 22, 0, 5);
this.di = this.e.copy().sub(this.p).limit(this.s);
this.p.add(this.di);
if(this.p.equals(this.e)) {
this.e = createVector(random(this.r/2, width-this.r/2), random(this.r/2, height-this.r/2));
this.s = 0;
this.d = this.p.dist(this.e);
}
}
show() {
strokeWeight(this.sW);
stroke(this.c);
noStroke();
fill(this.cc);
ellipse(this.p.x, this.p.y, this.r);
}
}