pakt02
See /f0blog/pact-februari/
//pakt02 missing dashed lines
int index, n;
PGraphics grad;
void setup() {
size(640, 480, JAVA2D);
frameRate(60);
noFill();
strokeWeight(1);
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.5*255.0, 0.6*255.0, 0.7*255.0), color(0, 0, 0));
grad.endDraw();
stroke(255.0, 255.0, 0.0, 0.8*255.0);
}
void draw() {
float x= 10.0+(sin(index*0.016)*2.0);
float y= (height*0.5)+(sin(index*0.010)*50.0);
float x3= width-10.0+(sin(index*0.012)*2.0);
float y3= (height*0.5)+(sin(index*0.014)*50.0);
float w= width*0.5;
float h= height*0.5;
float spread= map(sin(index*0.0005), -1.0, 1.0, 0.5, 1.5);
image(grad, 0, 0);
//double dashes[]= {sin(index*0.0023)*50.0+51.0, cos(index*0.0023)*50.0+51.0};
//set dash here TODO
for (int i= 0; i<n; i++) {
float x1= map(sin(index*0.135+(i*spread)), -1.0, 1.0, 0.1, 0.5);
float y1= cos((index+i)*0.130+(i*spread));
float x2= map(sin(index*0.125+(i*spread)), -1.0, 1.0, 0.5, 0.9);
float y2= cos((index+i)*0.120+(i*spread));
bezier(x, y, x1*w+w, y1*h+h, x2*w+w, y2*h+h, x3, y3);
}
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);
}
}