pakt14
See /f0blog/pact-februari/
//pakt14
int index;
float spread;
float spreadx, spready;
int n;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
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.5*255, 0.6*255), color(0, 0, 0));
grad.endDraw();
fill(255);
noStroke();
}
void draw() {
background(0);
blendMode(DIFFERENCE);
float x= 0, y= 0;
for (int i= 0; i<=n; i++) {
spreadx= sin((i+index)*0.011)*sin((i+index)*0.013);
spready= sin((i+index)*0.012)*sin((i+index)*0.014);
spread= (spreadx*spready)*0.25+cos((index+i)*0.001);
float yy= sin((i+index)*0.012+spready);
float hh= yy*(cos(index*0.013));
float xx= cos((i+index)*0.014+spreadx);
float ww= xx*(sin(index*0.015));
yy= yy*(height*spread)+(height*0.5);
xx= xx*(height*spread)+(height*0.5);
hh= hh*(height*spread)+(height*0.5);
ww= ww*(height*spread)+(height*0.5);
if (i==0) {
x= xx;
y= yy;
} else if (i%5==1) {
bezier(x, y, xx, yy, ww, hh, ww, hh);
x= ww;
y= hh;
} else if (i%5==2) {
bezier(x, y, yy, xx, hh, ww, hh, ww);
x= hh;
y= ww;
} else if (i%5==3) {
bezier(x, y, xx, yy, hh, ww, hh, ww);
x= hh;
y= ww;
} else if (i%5==4) {
bezier(x, y, yy, xx, ww, hh, ww, hh);
x= ww;
y= hh;
} else {
x= yy;
y= xx;
}
}
blendMode(LIGHTEST);
image(grad, 0, 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);
}
}