xxxxxxxxxx
78
let cols = ["#8ecae6","#57afd2","#219ebc","#1f6a92","#023047","#ffb703","#ff9d00","#fb8500","#ff6f00","#fb5f0a"];
let dots = [];
let c = 20;
let n = 10;
let time = 10;
let bgc = "#FFEDFE"
function setup() {
createCanvas(1920, 1080);
for(a = 0; a < width / c; a++){
for(b = 0; b < width / c; b++){
dots[dots.length] = new Dot(a * c + random(-c, c), b * c + random(-c, c) , dots.length);
}
}
// blendMode(ADD);
let bg = color(bgc);
background(bg);
noiseSeed(15);
}
function draw() {
time = time + 0.001
for(i = 0; i < dots.length; i++){
if(dots[i] !== undefined){
dots[i].update();
}
}
}
class Dot{
constructor(x, y, index){
this.pos = createVector(x, y);
this.vel = createVector(1, 0);
this.index = index;
this.t = 0;
this.tu = (floor(random(8)) + 1) * 40;
this.angleChance = floor(noise(this.pos.x / 200, this.pos.y / 200) * 8);
this.nf = 0;
this.vel.setHeading(TWO_PI / n * this.angleChance);
this.c = floor(this.index % cols.length);
this.col = color(cols[this.c]);
// this.col.setAlpha(2)
stroke(this.col);
strokeWeight(1);
if(this.c < 10){
this.c = this.c + 40
}
// circle(this.pos.x, this.pos.y, random(30, 40));
}
update(){
this.nf = noise(this.pos.x / map(noise(this.pos.x / 200, this.pos.y / 200, time), 0, 1, 50, 500), this.pos.y / map(noise(this.pos.x / 200, this.pos.y / 200, this.c / 50), 0, 1, 50, 500));
this.t ++;
// if(round(this.pos.x) % (c / 2) == 0 && round(this.pos.y) % (c / 2) == 0){
// this.angleChance = floor(this.nf * n);
// }
this.angleChance = floor(this.nf * n) * 4;
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;
// }
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);
}
}
}