239
edits
Line 209: | Line 209: | ||
for(int i=0; i<x.length; i++){ | for(int i=0; i<x.length; i++){ | ||
x[i]=(int)random(width); | x[i]=(int)random(width); // random position of the butterflies | ||
y[i]=(int)random(height); | y[i]=(int)random(height); | ||
w[i]=(int)random(20,80); | w[i]=(int)random(20,80); | ||
Line 222: | Line 222: | ||
for(int i=0; i<x.length-1; i++){ | for(int i=0; i<x.length-1; i++){ | ||
int newX=x[i]+=random(-stepLength,stepLength); | int newX=x[i]+=random(-stepLength,stepLength); //move the butterflies | ||
int newY=y[i]+=random(-stepLength,stepLength); | int newY=y[i]+=random(-stepLength,stepLength); | ||
if(newX<0) newX = width; | if(newX<0) newX = width; | ||
else if(newX>width) newX = 0; | else if(newX>width) newX = 0; | ||
if(newY<0) newY = height; | if(newY<0) newY = height; //keep them | ||
else if(newY>height) newY = height; | else if(newY>height) newY = height; | ||
x = append(x, newX); | x = append(x, newX); | ||
y = append(y, newY); | y = append(y, newY); // I guess this results in "butterfly effect" | ||
if(x.length > num){ | if(x.length > num){ | ||
Line 239: | Line 239: | ||
rect(x[i],y[i],w[i],h[i]); | rect(x[i],y[i],w[i],h[i]); | ||
} | } | ||
fill(x[i],y[i],150); | fill(x[i],y[i],150); //mellow colours | ||
} | } | ||
} | } |
edits