let n = 3; //  n is the ordering number of a floret, counting outward from the centre, it means n is the point that rectangle start//
let c = 6; // the rectangle size, c is a constant scaling parameter //



function setup() {

  let size = min(window.innerWidth, window.innerHeight); 
  createCanvas(size, size);
  noStroke();
  angleMode(DEGREES);
  colorMode(HSL, 360);
  background(0); //back bacground//
  

}

function draw() {
  
  let a = n * 137.6; // the value of the divergence angle, the angle is direction//
  let r = c * sqrt(n); 
  let x = r * cos(a) + width / 2; // r is the radius being the distance from 0-0//
  let y = r * sin(a) + height / 2; 

  fill(random(0,255),random(255,70),random(255,200));// fill random color//
  rect(x, y, 8, 8); //rectangle shape//
  n++; // arrays//

}



// reference//
//inspiration + explanation  for phyllotaxis https://www.youtube.com/watch?v=KWoJgHFYWxY//
//http://algorithmicbotany.org/papers/abop/abop-ch4.pdf//