fractalkitty looking for math? fractalkitty.com

optical illusions

OL_Pinna

#trig#animation

pinnapolygonangle

function setup() {
  createCanvas(400, 400);
  noFill();
  strokeWeight(2.5)
}

function draw() {
  background(180);
  translate(200,200)
  for(let i=0;i<8;i++){
    pinna(i*27)//make sure multiplier is odd
  }
}
function pinna(r){
  n=floor(r/2)
  if(n%2===1){
    n=n+1;
  }
  if (r%2===0){
    c=-1
  }else{c=1}
  d=5
  for(let i=0;i<n;i++){
      if(i%2==0){
        stroke(255)
      }else{
        stroke(0)
      }
      push()
      rotate(PI/15*c)
      rect(r*sin(TWO_PI/n*i),r*cos(TWO_PI/n*i),7,7)
      pop()
    }
    
}
function polygon(x, y, radius, npoints) {
  let angle = TWO_PI / npoints;
  beginShape();
  for (let a = 0; a < TWO_PI; a += angle) {
    let sx = x + cos(a) * radius;
    let sy = y + sin(a) * radius;
    vertex(sx, sy);
  }
  endShape(CLOSE);
}