xxxxxxxxxx
60
function setup() {
createCanvas(900, 900);
center = createVector(width / 2, height / 2);
placer = createVector(width / 2, 0);
dots = [];
cols = ["#041E29","#157C91","#2ceef2","#00FFAB","#5AFF50","#ffb01f","#fd8f21","#fc6722","#ea4334","#E62767"];
nzoom = width;
rspeed = 0.001;
for(i = 0; i < 10; i++){
dots[dots.length] = new Dot(center.x + placer.x, center.y + placer.y, dots.length);
placer.setHeading(placer.heading() + PI / 10);
}
background(30);
strokeWeight(1);
noFill();
}
function draw() {
for(a = 0; a < 100; a++){
for(i = 0; i < dots.length; i++){
dots[i].update();
}
}
}
class Dot{
constructor(x, y, index){
this.pos = createVector(x, y);
this.npos = createVector(x, y);
this.start = frameCount;
this.sp = p5.Vector.sub(this.pos, center);
this.rspeed = 0.001;
this.index = index;
this.col = color(cols[this.index % cols.length]);
this.fc = 0;
}
update(){
this.fc++;
this.rspeed = 0.1;
this.sp = p5.Vector.sub(this.pos, center);
this.sp.setMag(sin(this.fc / 10000 + this.index) * width / 4 + width / 4);
// this.sp.setHeading(sin(this.fc / 100) * (TWO_PI / 10 / 3 + TWO_PI / 10 / 4 + noise(this.pos.x / nzoom, this.pos.y / nzoom + this.fc / 100000)) + this.index * TWO_PI / 10 + this.fc * 0.000000001);
this.sp.setHeading(sin(this.sp.mag() / 500 + this.fc / 5000) * (TWO_PI / 10 + this.sp.mag() / 1000000) + this.index * TWO_PI / 10 + this.fc / 1000000);
this.npos = p5.Vector.add(center, this.sp);
if(this.fc > 5){
stroke(this.col);
// fill(this.col);
// line(this.pos.x, this.pos.y, this.npos.x, this.npos.y);
circle(this.pos.x, this.pos.y, this.sp.mag() / 75);
}
this.pos = p5.Vector.add(center, this.sp);
// point(this.pos.x, this.pos.y);
}
}