Phyllotaxis

Phyllotaxis is a botanic pattern of arrangment of leaves.
It even derives the name of the plant from the Greek word phýllon, meaning "leaf" and táxis meaning "arrangment" .
Here we use a polar equation to draw a phyllotaxis pattern.
It is an amazing example of mathematics and symmetry in nature.

Code

            
    elem=document.querySelector(".example-container");
    setCanvas(elem);
    
    c=8;   //change this to change the distance between points
    n=0;   //starting point of spiral
    t2=0;  // angle to keep the pattern rotating
    function draw() {

        clearCanvas();

        for(t=0;t<n;t++){
            var a = t * 137.5;
            var r = c * sqrt(t);      //polar equation
            
            var x = r * cos(a-t2);
            var y = r * sin(a-t2);       //cartesian form of the same equation
            
            ic=mapRange(t,0,n,0,360);     //map value to hue
            new circle(WIDTH/2+x,HEIGHT/2+y,5,`hsl(${ic},100%,50%)`,1,'#fff',0);
        }

        t2+=0.01;

        if(n<350){   
        n+=0.3;       //speed of growth
        }

        requestAnimationFrame(draw);

    }

    
    draw();