xxxxxxxxxx
51
class Dot{
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.index = index;
this.t = 0;
this.angleChance = 0;
this.nf = 0;
// this.vel.setHeading(TWO_PI / n * this.angleChance);
this.vel.setHeading(random(TWO_PI));
this.c = floor(this.index % cols.length);
// this.c = 2;
this.col = color(cols[this.c]);
// this.col.setAlpha(20)
stroke(this.col);
strokeWeight(1);
this.f = 1;
}
update(){
this.nf = noise(this.pos.x / 600, this.pos.y / 600);
this.t ++;
if(this.t % clock == 0){
if(this.t > 60 * r){
this.f = this.f * -1;
this.t = 0;
// r = floor(random(7));
}
this.angleChance = this.angleChance + 1 * this.f;
}
this.vel.setHeading(TWO_PI / n * this.angleChance);
// if(this.t > this.tu){
// circle(this.pos.x, this.pos.y, random(30, 40));
// this.angleChance = floor(this.nf * 16);
// this.vel.setHeading(TWO_PI / 8 * this.angleChance);
// this.tu = (floor(random(7)) + 2) * 40;
// this.t = 0;
// }
// this.col.setAlpha(10);
stroke(this.col);
point(this.pos.x, this.pos.y);
this.pos.add(this.vel);
if(this.pos.x < 0 - 10 || this.pos.y < 0 - 10 || this.pos.x > width + 10 || this.pos.y > height + 10){
dots[this.index] = undefined;
// dots[dots.length] = new Dot(random(width), random(height), dots.length);
}
}
}