‹ pakt20pakt22 ›

pakt21

See /f0blog/pact-februari/

//pakt21

int index, n;
float[][] last;
color[] cols;
float spread;

void setup() {
  size(640, 480, JAVA2D);
  frameRate(60);
  smooth();
  noStroke();
  n= 150;
  index= 0;
  last= new float[n][2];
  cols= new color[n];
  for (int i= 0; i<n; i++) {
    float t= float(i)/n*TWO_PI;
    last[i][0]= 0.0;
    last[i][1]= 0.0;
    cols[i]= color(sin(t)*127.5+127.5, sin(t+PI)*127.5+127.5, 255.0);
  }
  background(0);
}
void draw() {
  fill(color(0, 0, 0, 13));
  rect(0, 0, width, height);
  for (int i= 0; i<n; i++) {
    float x= sin((i*(sin(index*0.0126+(sin(i)*sin(i*2)))*sin(index*0.0031))+index)*0.074);
    float y= cos((i*(sin(index*0.0152+(sin(i)*sin(i*2)))*sin(index*0.0021))+index)*0.064);
    float[] pos= {
      x*width*0.45+(width*0.5), y*height*0.45+(height*0.5)
    };
    if (index>0) {
      fill(cols[i]);
      float r= abs((pos[0]-last[i][0])+(pos[1]-last[i][1]))*0.5;
      ellipse(pos[0], pos[1], r*2.0, r*2.0);
    }
    last[i][0]= pos[0];
    last[i][1]= pos[1];
  }
  index++;
}