‹ pakt00 pakt02 ›

pakt01

See /f0blog/pact-februari/

//pakt01 ok - but no changing background

int index, n;
PGraphics grad;

void setup() {
  size(640, 480, JAVA2D);
  frameRate(60);
  noFill();
  strokeCap(SQUARE);
  smooth();
  index= 0;
  n= 75;
  grad= createGraphics(width, height, JAVA2D);
  grad.beginDraw();
  grad.background(0);
  createGradient(grad, width*0.5, height*0.5, width*2.0, color(255.0, 255.0, 0.65*255.0), color(0, 0, 0));
  grad.endDraw();
}
void draw() {
  float x= width*0.5;
  float y= height*0.5;
  float w= width*0.25;
  float h= height*0.25;
  float yellow= sin(index*0.0005)*0.3+0.65;

  image(grad, 0, 0);

  for (int i= 0; i<n; i++) {
    float xx= x+(cos(i*0.2)*w);
    float yy= y+(sin(i*0.15)*h);
    float start= cos(index*((i+1)*0.00006))*TWO_PI;
    float end= sin(index*((i*1)*0.00008))*TWO_PI;
    float sze= sin(index*0.01+i)*50.0+58.0;
    stroke(xx/float(width)*255.0, yy/float(height)*255.0, yellow*255.0, end/2*PI*255.0);
    strokeWeight(i/8.0+4.0);
    arc(xx, yy, sze, sze, start, start+end);
  }
  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);
  }
}