‹ pakt12pakt14 ›

pakt13

See /f0blog/pact-februari/

//pakt13

int index;
float rows, cols;
PGraphics grad;

void setup() {
  size(640, 480, JAVA2D);
  frameRate(60);
  index= 0;
  rows= 11.0;
  cols= 11.0;
  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.6*255, 0.5*255), color(0, 0, 0));
  grad.endDraw();
  fill(255);
  noStroke();
}
void draw() {
  background(0);
  blendMode(DIFFERENCE);
  beginShape(QUADS);
  for (int y= 0; y<=rows; y++) {
    for (int x= 0; x<=cols; x++) {
      float xx= x/rows*width-2;
      float yy= y/cols*height-2;
      float vx= sin(index+(x*y))*(sin((index+x)*0.0015)+sin((index+y)*0.0062)*10.0);
      float vy= cos(index+(x*y))*(sin((index+y)*0.0325)+sin((index+y)*0.0072)*10.0);
      vertex(vx-xx, vy-yy);
      vertex(vx+xx, vy-yy);
      vertex(vx+xx, vy+yy);
      vertex(vx-xx, vy+yy);
    }
  }
  endShape();
  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);
  }
}