fractalkitty looking for math? fractalkitty.com

100 days of code

phiWater

#trig#animation#math#spiral#polar

polygonangle

let n=200;
let s = 2;
function setup(){
  createCanvas(windowWidth,windowHeight);
  angleMode(DEGREES);
 
  noStroke();
}
function draw(){
  background(255,255,255,50);
  t=frameCount/10;
  translate(width/2,height/2);
  for (let i = 0; i<n; i++){
    fill(250-100*sin(t),200-50*cos(t),205-50*sin(t),150)
    push()
    rotate(t)
    rotate(137.5*i)
    polygon(0,i*3+ 3*sin(t),i/2 +i/10*sin(t),s+2*s*sin(t)*sin(t));
    pop()
    fill(250-100*sin(t),200-50*cos(t),205-50*sin(t),150)
    push()
    rotate(-t)
    scale(-1,1)
    rotate(-137.5*i)
    polygon(0,i*3+ 3*sin(t),i/2 +i/10*sin(t),s+2*s*sin(t)*sin(t));
    pop()
  }
}
function polygon(x, y, radius, npoints) {
  let angle = 360 / npoints;
  beginShape();
  for (let a = 0; a < 360; a += angle) {
    let sx = x + cos(a) * radius;
    let sy = y + sin(a) * radius;
    vertex(sx, sy);
  }
  endShape(CLOSE);
}