let cArray = []//circle array
let a,b,c;//color randomizers
let r1=0;g1=0;b1=0;
function setup() {
if(windowWidth>=windowHeight){
createCanvas(windowWidth*0.98
, windowHeight/2);//different screen sizes produce
}else{
createCanvas(windowWidth/2
, windowWidth*0.98);//different screen sizes produce very different densities
}
noStroke()
for(let i = 0;i<floor(random(10,50));i++){
cArray[i] = createVector(random(0,width),random(0,height),random(2,width/5));
}
a=random(1,10)
b=random(1,5)
c=random(1,5)
angleMode(DEGREES)
}
function draw() {
n=40
t=frameCount;
d=max(width/n+100,height/n+100);
if(t%1440===0){
for(let i = 0;i<floor(random(10,50));i++){
cArray[i] = createVector(random(0,width),random(0,height),random(2,width/5));
}
}
for (let i =-1;i<=n;i++){
for (let j =-1;j<=n;j++){
x=width/n*i+random(-d,d);
y=height/n*j+random(-d,d);
let f= false
let p=0;
for(let k = 0;k<cArray.length;k++){
dist1 = dist(cArray[k].x,cArray[k].y,x,y)
if(dist1<cArray[k].z){
f=true;
p=k;
}
if(f && 100*abs(sin(t/10))>20){
r1=j*b+p*c+3*(a+b)*sin(t)*cos(t/2)-cArray[p].z/4-p;
g1=(a*b)+b*j+p*a+3*(p+a)*sin(t/2)+(a+b)*cos(t+p);
b1=i*b+20+p*(a+b)+4*(p+b)*sin(t/3)+x/20;
}else{
r1=i*b+20*cos(t);
g1=j*b+(b*c)+i*c+20*cos(t);
b1=(a*c)+c*j+(a*b)*i+20*cos(t);
}
if(x<10||y<10||x>width-10||y>height-10){
r1=0
g1=0
b1=0
}
}
fill(r1,g1,b1);
circle(x,y,random(0.5,2.5));
}
}
}
function mousePressed(){
cArray=[];
for(let i = 0;i<floor(random(10,50));i++){
cArray[i] = createVector(random(0,width),random(0,height),random(2,width/5));
}
a=random(1,10)
b=random(1,5)
c=random(1,5)
angleMode(DEGREES)
draw()
}
function windowResized(){
setup()
draw()
}