pakt10
See /f0blog/pact-februari/
//pakt10
int index, n;
float rows, cols;
float rowMod, colMod;
float magic;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
smooth();
index= 0;
n= 1200;
rows= 11;
cols= 12;
rowMod= 2.0;
colMod= 3.0;
magic= 0.0;
grad= createGraphics(width, height, JAVA2D);
grad.beginDraw();
grad.background(0);
createGradient(grad, width*0.5, height*0.5, width*2.0, color(0.2*255, 0.2*255, 0.5*255), color(0, 0, 0));
grad.endDraw();
stroke(255.0, 255.0, 0.2*255.0, 0.85*255.0);
}
void draw() {
float r= rows+(sin(index*0.013)*rowMod)+(sin(index*0.00133)*rowMod*0.56);
float c= cols+(cos(index*0.022)*colMod)+(cos(index*0.00122)*colMod*0.45);
image(grad, 0, 0);
for (int i= 0; i<n; i++) {
float px= (r+i)%width;
float py= ((c+i)*(i%(magic+1.01)))%height;
line(px, py, px+(10.0+sin((index+i)*0.02)), py+(10.0*cos((index+i)*0.03)));
}
rows= rows+(sin(index*0.0004));
cols= cols+(sin(index*0.0005));
index++;
magic= (magic+0.00002)%15.0;
}
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);
}
}