‹ pakt07pakt09 ›

pakt08

See /f0blog/pact-februari/

//pakt08 not the exact correct filling rule

int n;
float d, speed, spread, theta;
float[][] pnts;

void setup() {
  size(640, 480, JAVA2D);
  frameRate(60);
  n= 25;
  d= 0.0001;
  speed= 0.00002;
  spread= 2.0;
  theta= 0.0;
  pnts= new float[n][2];
  for (int i= 0; i<n; i++) {
    pnts[i][0]= width*0.5;
    pnts[i][1]= height*0.5;
  }
  fill(255.0, 0.0, 0.0);
  blendMode(DIFFERENCE);
  noStroke();
}
void draw() {
  background(0);
  float xx= width*0.5, yy= height*0.5;
  beginShape();
  for (int i= 0; i<n; i++) {
    float c= cos(theta+(i*d));
    float s= sin(theta+(i*d));
    float x= (pnts[i][0]/width)*2.0-1.0;
    float y= (pnts[i][1]/height)*2.0-1.0;
    float vx= (((c*x)-(s*y))*0.5+0.5)*width+spread;
    float vy= (((c*y)+(s*x))*0.5+0.5)*height+spread;
    pnts[i][0]= vx;
    pnts[i][1]= vy;
    vertex(xx, yy);
    xx= vx;
    yy= vy;
    theta= theta+speed;
  }
  endShape();
}