Public
Edited
Jul 27, 2023
1 fork
1 star
Insert cell
Insert cell
container = container_from(canvas);
Insert cell
sketch = function( p ) {

const radius = Math.sqrt(0.5);
const dotSize = 0.05;
const PHI = (1 + Math.sqrt(5)) / 2;
const count = 1000;
p.setup = function() {
p.createCanvas(800, 800);
p.noStroke();
}

p.draw = function() {
p.scale(p.width, p.height);
p.background(0);
p.fill(255);

for (let i = 1; i < count; i++) {
let f = i / count;
let angle = i * PHI;
let dist = f * radius;
let x = 0.5 + p.cos(angle * p.TWO_PI) * dist;
let y = 0.5 + p.sin(angle * p.TWO_PI) * dist;

const r = f * dotSize;

// p.circle(x, y, r);
p.rect(x, y, r, r);
}
}

}
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more