Public
Edited
Oct 24, 2023
1 fork
4 stars
Insert cell
Insert cell
Insert cell
view = {
const context = DOM.context2d(width, height);
context.clearRect(0, 0, width, height);

context.fillStyle = "black";
context.beginPath();
voronoi.delaunay.renderPoints(context, 1);
context.fill();

context.lineWidth = 1.5;

const segments = voronoi.render().split(/M/).slice(1);

let i = 0;
for (const e of segments) {
context.beginPath();
context.strokeStyle = d3.hsl(360 * Math.random(), 0.7, 0.5);
context.stroke(new Path2D("M" + e));
if (i++ % 5 === 0) yield context.canvas;
}
}
Insert cell
Insert cell
voronoi = new d3.Delaunay(positions).voronoi([1, 1, width - 1, height - 1])
Insert cell
n = 1500
Insert cell
height = Math.min(600, width)
Insert cell
positions = {
replay;
const randomX = d3.randomNormal(width / 2, height / 3);
const randomY = d3.randomNormal(height / 2, height / 3);
return Float64Array.from({length: n * 2}, (_, i) => i & 1 ? randomY() : randomX())
}
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