xxxxxxxxxx
44
function setup() {
// All our dimensions and rendering units will use inches
let units = 'in';
// Set canvas dimensions to 3000 units
let dimensions = [3000, 3000];
// Create a canvas with dimensions in pixels
createCanvas(dimensions[0], dimensions[1]);
// Set background to black
background(0);
// Use a white stroke for the points
stroke(255);
// Make circles expand to edge of the canvas
let maxRadius = min(width, height) / 2;
// Draw points
let points = 900;
for (let i = 1; i <= points; i++) {
let t = i / points;
// Here phi is the golden ratio
let phi = (sqrt(5) + 1) / 2;
// Pick our angle based on the golden ratio
let theta = 2 * PI * i * phi;
// Get back a distance 0..1 based on the current step
let distance = sqrt(t);
// Find the cartesian point on a unit circle
let x = cos(theta);
let y = sin(theta);
// Scale this point to our max dimensions
let r = distance * maxRadius;
// Find the point on the canvas
let cx = width / 2 + x * r;
let cy = height / 2 + y * r;
// Now draw a circle at each point
// Make them smaller when closer to centre
let radius = 0.02 * pow(t, 0.5) * maxRadius;
ellipse(cx, cy, radius * 2);
}
}