xxxxxxxxxx
168
let dots = [];
let cols = ["#0d3b66","#faf0ca","#f4d35e","#ee964b","#f96a4d","#fb5012","#e7dff7","#76ecf9","#508ab9","#423a38"];
let dens = 200;
let cdens = 20;
function setup() {
createCanvas(901, 901);
for(y = 0; y < 5000; y++){
dots[dots.length] = new Dot(random(width), random(height), dots.length);
}
for(i = 0; i < dots.length; i++){
dots[i].closest();
}
}
function draw() {
background(255);
for(i = 0; i < dots.length; i++){
dots[i].update();
}
}
class Dot{
constructor(x, y, index){
this.x = x;
this.y = y;
this.index = index;
this.c = floor(random(cols.length));
this.col = color(cols[this.c]);
this.r = 0;
this.g = 0;
this.b = 0;
this.t1 = 0;
this.t2 = 0;
this.t3 = 0;
this.nf1 = 0;
this.nf2 = 0;
this.nf3 = 0;
this.i = 0;
this.dist = 0;
this.c1 = undefined;
this.c2 = undefined;
this.c3 = undefined;
this.c4 = undefined;
this.c5 = undefined;
this.c6 = undefined;
this.c7 = undefined;
this.c8 = undefined;
this.c1d = 0;
this.c2d = 0;
this.c3d = 0;
this.c4d = 0;
this.c5d = 0;
this.c6d = 0;
this.c7d = 0;
this.c8d = 0;
this.change = floor(random(30, 240));
if(this.index % cdens == 0){
this.r = red(this.col);
this.g = green(this.col);
this.b = blue(this.col);
}
}
closest(){
for(this.i = 0; this.i < dots.length; this.i++){
this.dist = dist(this.x, this.y, dots[this.i].x, dots[this.i].y);
if(this.c1 == undefined){
this.c1 = dots[this.i];
this.c1d = this.dist;
}
else if(this.c2 == undefined){
this.c2 = dots[this.i];
this.c2d = this.dist;
}
else if(this.c3 == undefined){
this.c3 = dots[this.i];
this.c3d = this.dist;
}
else if(this.c4 == undefined){
this.c4 = dots[this.i];
this.c4d = this.dist;
}
else if(this.c5 == undefined){
this.c5 = dots[this.i];
this.c5d = this.dist;
}
else if(this.c6 == undefined){
this.c6 = dots[this.i];
this.c6d = this.dist;
}
else if(this.c7 == undefined){
this.c7 = dots[this.i];
this.c7d = this.dist;
}
else if(this.c8 == undefined){
this.c8 = dots[this.i];
this.c8d = this.dist;
}
if(this.c8 !== undefined){
if(this.dist < this.c1d){
this.c1 = dots[this.i];
this.c1d = this.dist;
}
else if(this.dist < this.c2d){
this.c2 = dots[this.i];
this.c2d = this.dist;
}
else if(this.dist < this.c3d){
this.c3 = dots[this.i];
this.c3d = this.dist;
}
else if(this.dist < this.c4d){
this.c4 = dots[this.i];
this.c4d = this.dist;
}
else if(this.dist < this.c5d){
this.c5 = dots[this.i];
this.c5d = this.dist;
}
else if(this.dist < this.c6d){
this.c6 = dots[this.i];
this.c6d = this.dist;
}
else if(this.dist < this.c7d){
this.c7 = dots[this.i];
this.c7d = this.dist;
}
else if(this.dist < this.c8d){
this.c8 = dots[this.i];
this.c8d = this.dist;
}
}
}
}
update(){
// this.t1 = this.t1 + 0.001;
// this.t2 = this.t2 + 0.002;
// this.t3 = this.t3 + 0.003;
// this.nf1 = noise(this.t1, this.index / 50);
// this.nf2 = noise(this.t2, this.index / 50);
// this.nf3 = noise(this.t3, this.index / 50);
if(this.index % cdens !== 0){
this.r = (this.r + this.c1.r + this.c2.r + this.c3.r + this.c4.r + this.c5.r + this.c6.r + this.c7.r + this.c8.r) / 9;
this.g = (this.g + this.c1.g + this.c2.g + this.c3.g + this.c4.g + this.c5.g + this.c6.g + this.c7.g + this.c8.g) / 9;
this.b = (this.b + this.c1.b + this.c2.b + this.c3.b + this.c4.b + this.c5.b + this.c6.b + this.c7.b + this.c8.b) / 9;
}
if(frameCount % this.change == 0){
if(this.index % cdens == 0){
this.c++;
if(this.c == cols.length) this.c = 0;
this.col = color(cols[this.c]);
this.r = red(this.col);
this.g = green(this.col);
this.b = blue(this.col);
}
}
noStroke();
fill(this.r, this.g, this.b);
circle(this.x, this.y, 40);
}
}