pakt11
See /f0blog/pact-februari/
//pakt11
int index;
float rowsMid, colsMid, rows, cols;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
noStroke();
smooth();
index= 0;
rowsMid= 22.0;
colsMid= 20.0;
scale(0.96, 0.96);
translate(5.0, 5.0);
grad= createGraphics(width, height, JAVA2D);
grad.beginDraw();
grad.background(0);
createGradient(grad, width*0.5, height*0.5, width*2.0, color(0.6*255, 0.5*255, 0.5*255), color(0, 0, 0));
grad.endDraw();
fill(255.0);
}
void draw() {
rows= rowsMid+(sin(index*0.0015)*10.0);
cols= colsMid+(sin(index*0.0024)*10.0);
image(grad, 0, 0);
float x1= 0, y1= 0, x2= 0, y2= 0;
scale(0.96);
translate(5, 5);
beginShape();
vertex(0, 0);
for (int y= 0; y<=int(rows); y++) {
for (int x= 0; x<=int(cols); x++) {
float xx= x;
float yy= y;
x1= (xx/rows*width)+sin(index+(xx*yy)*32.0);
y1= (yy/cols*height)+cos(index+(xx*yy)*24.0);
x2= (xx/cols*width)+sin(index+(xx*yy)*32.0);
y2= (yy/rows*height)+cos(index+(xx*yy)*24.0);
vertex(x1, y1);
vertex(x2, y2);
}
}
endShape();
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);
}
}