‹ pakt11pakt13 ›

pakt12

See /f0blog/pact-februari/

//pakt12

int index;
float n;
PGraphics grad;

void setup() {
  size(640, 480, JAVA2D);
  frameRate(60);
  noStroke();
  smooth();
  index= 0;
  strokeWeight(1);
  grad= createGraphics(width, height, JAVA2D);
  grad.beginDraw();
  grad.background(0);
  createGradient(grad, width*0.5, height*0.5, width*2.0, color(0.3*255, 0.3*255, 0.3*255), color(0, 0, 0));
  grad.endDraw();

  fill(255.0, 255.0, 255.0, 0.7*255.0);
}
void draw() {
  image(grad, 0, 0);

  n= sin(index/frameRate*0.125)*150.0+200.0;
  float x= 0, y= 0, xx= 0, yy= 0;
  beginShape();
  for (int i= 0; i<int(n); i++) {
    if (i==0) {
      x= 0.5/n*width;
      y= height*0.5;
    } else if (i%3==1) {
      xx= i/n*width;
      yy= (height*0.25)+(sin((index+(i+3))*(sin((index+1)*0.014)*0.02))*(sin((index+i)*0.015))*(0.225*height));
      vertex(x, y);
      x= xx;
      y= yy;
    } else if (i%3==2) {
      xx= i/n*width;
      yy= (height*0.50)+(sin((index+(i+2))*(sin((index+2)*0.012)*0.02))*(sin((index+i)*0.020))*(0.225*height));
      vertex(x, y);
      x= xx;
      y= yy;
    } else {
      xx= i/n*width;
      yy= (height*0.75)+(sin((index+(i+1))*(sin((index+3)*0.010)*0.02))*(sin((index+i)*0.025))*(0.225*height));
      vertex(x, y);
      x= xx;
      y= yy;
    }
  }
  vertex(width*0.99, height*0.5);
  endShape();
  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);
  }
}