4

A regular grid emerges / Mark Seemann / Observable

 1 year ago
source link: https://observablehq.com/@ploeh/a-regular-grid-emerges
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

A regular grid emerges

Helps programmers make code easier to maintain.
Public
Edited
Mar 22, 2021
1 Like
function* lloydRelax(points, context, iterations) {
const diameter = circleRadius * 2;
const voronoi = new d3.Delaunay(points).voronoi(getBounds(points.length / 2).bounds);
for (let i = 0; i < iterations; i++) {
context.clearRect(0, 0, width, height);
context.beginPath();
lloydIteration(points, voronoi, context);
context.stroke();
if (showCounters) {
context.font = "50% monospace";
context.fillText(`Blobs: ${(points.length / 2).toString().padStart(4, " ")}`, 1, 10);
context.fillText(`Iterations: ${i.toString().padStart(4, "0")}`, 1, 20);
yield context.canvas;
voronoi.update();

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK