239
edits
Line 194: | Line 194: | ||
|[[File:butterflies (Konvertiert)-quicktime.mov]] | |[[File:butterflies (Konvertiert)-quicktime.mov]] | ||
|<source lang=java> | |<source lang=java> | ||
int num= | int num=50; //number of butterflies, but actually around 5 "form" one... | ||
int stepLength=10; //tempo of them | int stepLength=10; //tempo of them | ||
Line 204: | Line 204: | ||
void setup() { | void setup() { | ||
rectMode(CENTER); | rectMode(CENTER); | ||
size( | size(1280,720); | ||
background(255); | background(255); | ||
noStroke(); | noStroke(); | ||
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