xxxxxxxxxx
44
// https://thecodingtrain.com/CodingChallenges/030-phyllotaxis.html
let n = 0;
let c = 3;
let diam = 2;
const colors = [ "#ffcc00", "#005f73", "#0a9396", "#94d2bd", "#e9d8a6", "#ee9b00", "#ca6702", "#bb3e03", "#ae2012", "#620f12" ];
function setup() {
createCanvas(600, 600);
angleMode(DEGREES);
// colorMode(HSB)
background(20);
}
// let angles = [137.1, 137.2, 137.3, 137.5, 137.6, 137.7, 17.3];
let angles = [90.6, 180.3, 30.1, 239.9];
// let angles = [120.3, 90.7, 60.5, 30.6, 15.2];
// let angles = [120, 90, 60, 30, 15];
function draw() {
translate(width / 2, height / 2);
noStroke();
for(let i = 0; i < angles.length; i++) {
let angle = n*angles[i];
let radius = c * sqrt(n)
let x = radius * cos(angle);
let y = radius * sin(angle);
fill(colors[i%colors.length]);
// colorMode(HSB)
// fill(n%256, 255, 255);
ellipse(x,y, diam, diam);
}
n+=2;
}
function mousePressed() {
noLoop();
}