pakt03
See /f0blog/pact-februari/
//pakt03
int index, n;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
noStroke();
smooth();
index= 0;
n= 50;
grad= createGraphics(width, height, JAVA2D);
grad.beginDraw();
grad.background(0);
createGradient(grad, width*0.5, height*0.5, width*2.0, color(0.7*255.0, 0.6*255.0, 0.5*255.0), color(0, 0, 0));
grad.endDraw();
}
void draw() {
float x= width*0.5;
float y= height*0.5;
float w= width*0.4;
float h= height*0.4;
float spreadx= sin(index*0.005);
float spready= sin(index*0.011);
float phaseshift= sin(index*0.001)*TWO_PI;
float wx= w*(sin(index*0.004)*0.45+0.55);
float hy= h*(sin(index*0.004)*0.45+0.55);
image(grad, 0, 0);
for (int i= 0; i<n; i++) {
float r= i/float(n)*30.0+1.0;
float p= 0.0;
fill(255.0, 255.0, 255.0, 0.5*255.0);
ellipse(x+(sin((index+(i*spreadx))*0.05+p)*wx), y+cos((index+(i*spready))*0.05+p)*hy, r*2.0, r*2.0);
p= p+phaseshift;
fill(0.0, 0.0, 255.0, 0.5*255.0);
ellipse(x+(sin((index+(i*spreadx))*0.05+p)*wx), y+cos((index+(i*spready))*0.05+p)*hy, r*2.0, r*2.0);
/*
p= p+phaseshift;
fill(0.0, 255.0, 0.0, 0.5*255.0);
ellipse(x+(sin((index+(i*spreadx))*0.05+p)*wx), y+cos((index+(i*spready))*0.05+p)*hy, r*2.0, r*2.0);
p= p+phaseshift;
fill(255.0, 0.0, 0.0, 0.5*255.0);
ellipse(x+(sin((index+(i*spreadx))*0.05+p)*wx), y+cos((index+(i*spready))*0.05+p)*hy, r*2.0, r*2.0);
p= p+phaseshift;
fill(0.0, 0.0, 0.0, 0.5*255.0);
ellipse(x+(sin((index+(i*spreadx))*0.05+p)*wx), y+cos((index+(i*spready))*0.05+p)*hy, r*2.0, r*2.0);
*/
}
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);
}
}