xxxxxxxxxx
// BASED ON :
// Daniel Shiffman
// http://codingtra.in
// http://patreon.com/codingtrain
// Code for: https://youtu.be/KWoJgHFYWxY
var n = 0;
var c = 3;
function setup() {
createCanvas(800, 800);
angleMode(DEGREES);
}
function draw() {
background(0);
phyllotaxis(30, 5);
// The first paramater change the global size of this algorithm.
// The second one change the distance between each spot
// Change them to discover how they work
}
function phyllotaxis(size, step)
{
for (var n = 0; n <=size; n+=5)
{
for (var i = 0; i < n; i++)
{
var a = i * 137.5;
var r = c * sqrt(i) * step;
var x = r * cos(a);
var y = r * sin(a);
fill(255);
noStroke();
ellipse(width/2 + x, height/2 + y, 4, 4);
// You can add Tree Pictures instead of drawing ellipses, or keep the ellipses :)
}
}
}