pakt05
See /f0blog/pact-februari/
//pakt05
int index, n;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
strokeWeight(1);
smooth();
index= 0;
n= 100;
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, 0.4*255.0, 0.3*255.0), color(0, 0, 0));
grad.endDraw();
stroke(255.0, 255.0, 255.0, 0.8*255.0);
}
void draw() {
float x= width*0.5;
float y= height*0.5;
float w= width*0.3;
float h= height*0.275;
float spread= sin(index*0.0012)*20.0;
float speed1= sin(index*0.0013)*0.001+0.005;
float speed2= sin(index*0.0014)*0.001+0.0005;
float speed3= sin(index*0.0015)*0.001+0.014;
float speed4= sin(index*0.0016)*0.001+0.012;
image(grad, 0, 0);
for (int i= 0; i<n; i++) {
float px= x+(sin((index*i*speed1))+sin(index*i*speed2)*w)-i;
float py= y+sin((index+(i*spread))*speed3)*sin((index+i)*speed4)*h+i;
line(px+(n-i), py+(i-n), px, py);
}
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);
}
}