viewof valuesClipped = {
const rad = borderradius;
const context = DOM.context2d(width, height, 1),
path = d3.geoPath().context(context);
const contextGrey = DOM.context2d(width, height, 1);
const greys = d3
.scaleSequential(t => d3.rgb((t *= 256), t, t))
.domain([0, 256]);
context.fillStyle = color(0);
context.fillRect(0, 0, width, height);
contextGrey.fillStyle = greys(0);
contextGrey.fillRect(0, 0, width, height);
for (let i = 0; i < data.length; i++) {
context.save();
context.beginPath();
context.arc(data[i][0], data[i][1], rad, 0, 7);
context.clip();
context.beginPath();
voronoi.renderCell(i, context);
context.strokeStyle = context.fillStyle = color(data[i][2]);
context.fill();
context.stroke();
context.restore();
contextGrey.save();
contextGrey.beginPath();
contextGrey.arc(data[i][0], data[i][1], rad, 0, 7);
contextGrey.clip();
contextGrey.beginPath();
voronoi.renderCell(i, contextGrey);
contextGrey.strokeStyle = contextGrey.fillStyle = greys(data[i][2]);
contextGrey.fill();
contextGrey.stroke();
contextGrey.restore();
}
for (const d of data) {
context.beginPath();
path({ type: "Point", coordinates: d });
context.fillStyle = color(d[2]);
context.fill();
context.strokeStyle = "#fff";
context.stroke();
}
const g = contextGrey.getImageData(0, 0, width, height).data;
return Object.assign(context.canvas, {
value: Float32Array.from(
{ length: width * height },
(_, i) => g[i * 4] + .001
)
});
}