pakt09
See /f0blog/pact-februari/
//pakt09
int index, n, m;
float rows, cols;
float magic;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
noStroke();
index= 0;
n= 1000;
m= 0;
rows= 3;
cols= 4;
magic= 50;
grad= createGraphics(width, height, JAVA2D);
grad.beginDraw();
grad.background(0);
createGradient(grad, width*0.5, height*0.5, width*2.0, color(0.5*255, 0.5*255, 0.5*255), color(0, 0, 0));
grad.endDraw();
fill(255.0, 255.0, 255.0, 0.85*255.0);
}
void draw() {
image(grad, 0, 0);
if (m<n) {
m= m+1;
}
for (int i= 0; i<m; i++) {
float px= (rows+i)%width;
float py= ((cols+i)*(i%magic))%height;
rect(px, py, 8.0*sin((index+i)*0.012), 8.0*cos((index+i)*0.011));
}
magic= magic+(sin(index*0.001)*0.01);
rows= rows+(sin(index*0.0004));
cols= cols+(sin(index*0.0005));
index++;
}
void createGradient(PGraphics ctx, float x, float y, float radius, color c1, color c2) {
ctx.noStroke();
for (float r= radius; r>=0.0; r--) {
color col= lerpColor(c1, c2, r/radius);
ctx.fill(col);
ctx.ellipse(x, y, r, r);
}
}