‹ pakt07pakt09 ›

pakt08

See /f0blog/pact-februari/

//pakt08
//wrong filling rule
int n;
float w, h;
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;
  }
  w= width;
  h= height;
  //noStroke();
  fill(255.0, 0.0, 0.0);
}
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]/w)*2.0-1.0;
    float y= (pnts[i][1]/h)*2.0-1.0;
    float vx= (((c*x)-(s*y))*0.5+0.5)*w+spread;
    float vy= (((c*y)+(s*x))*0.5+0.5)*h+spread;
    pnts[i][0]= vx;
    pnts[i][1]= vy;
    vertex(xx, yy);
    xx= vx;
    yy= vy;
    theta= theta+speed;
  }
  endShape();
}
/*
void draw() {
 background(0);
 float xx= width*0.5, yy= height*0.5;
 for(int i= 0; i<n; i++) {
 float c= cos(theta+(i*d));
 float s= sin(theta+(i*d));
 float x= (pnts[i][0]/w)*2.0-1.0;
 float y= (pnts[i][1]/h)*2.0-1.0;
 float vx= (((c*x)-(s*y))*0.5+0.5)*w+spread;
 float vy= (((c*y)+(s*x))*0.5+0.5)*h+spread;
 pnts[i][0]= vx;
 pnts[i][1]= vy;
 line(xx, yy, vx, vy);
 xx= vx;
 yy= vy;
 theta= theta+speed;
 }
 }
 */