xxxxxxxxxx
83
function setup() {
createCanvas(1080, 1080);
nzoom = 5;
stutter = 1;
dots = [];
cols = ["#041E29","#157C91","#2ceef2","#00FFAB","#5AFF50","#ffb01f","#fd8f21","#fc6722","#ea4334","#E62767"];
zcenter = createVector(width / 2, height / 2);
c1 = 0;
c2 = 1;
la = 0;
it = 10;
col = undefined;
dens = 10;
for(i = 0; i < width / dens; i++){
for(j = 0; j < height / dens; j++){
dots[dots.length] = new Dot(i * dens + random(-dens, dens), j * dens + random(-dens, dens), dots.length);
}
}
strokeWeight(0.1)
}
function draw() {
// zcenter = createVector(noise(frameCount * 0.001) * width, noise((frameCount + 50) * 0.001) * height)
// stutter = stutter + 0.01;
it = it + 2;
col = lerpColor(cols[c1],cols[c2],la)
la = la + 0.01;
if(la >= 1){
stutter++;
la = 0;
// zcenter = createVector(random(width), random(height));
if(c2 < cols.length - 1){
c1 = c2;
c2++;
}else{
c1 = c2;
c2 = 0;
}
}
background(0, 0.2);
stroke(col);
for(i = 0; i < dots.length; i++){
if(dots[i] !== undefined){
dots[i].update();
}
}
nzoom = nzoom + 0.005;
}
class Dot {
constructor(x, y, index){
this.pos = createVector(x, y);
this.opos = createVector(x, y);
this.npos = createVector(x, y);
this.vel = createVector(1, 0);
this.sp = p5.Vector.sub(this.pos, zcenter);
this.nzoom = this.sp.mag() % 30 * 5;
this.nf = 0;
this.index = index;
}
update(){
this.sp = p5.Vector.sub(this.pos, zcenter);
this.nzoom = atan(this.pos.y - zcenter.y + this.pos.x - zcenter.x + frameCount * 0.1) * 50;
this.nf = noise((this.pos.x - zcenter.x) / this.nzoom , (this.pos.y - zcenter.y) / this.nzoom, frameCount * 0.001);
// this.vel.setHeading(this.sp.heading() + QUARTER_PI + this.nf * TWO_PI);
this.vel.setHeading(this.nf * TWO_PI * 2);
this.npos.add(this.vel);
line(this.pos.x, this.pos.y, this.npos.x, this.npos.y);
this.pos.add(this.vel);
if(this.pos.x < 0 || this.pos.x > width || this.pos.y < 0 || this.pos.y > height|| la >= 0.99){
this.pos = createVector(this.opos.x, this.opos.y);
this.npos = createVector(this.opos.x, this.opos.y);
}
}
}