viewof point = {
const sphere = {type: "Sphere"};
const graticule = d3.geoGraticule10();
const height = width / 2;
const context = DOM.context2d(width, height);
const projection = d3.geoEqualEarth().fitSize([width, height], {type: "Sphere"});
const path = d3.geoPath(projection, context);
let mousedown = false;
context.beginPath(), path(graticule), context.strokeStyle = "#ccc", context.stroke();
context.beginPath(), context.fillStyle="#ccc", path(land), context.fill();
context.beginPath(), path(sphere), context.strokeStyle = "#000", context.stroke();
context.beginPath(), path.pointRadius(.5); path(geojson), context.stroke();
context.lineWidth = 2, context.strokeStyle = "#f00";
const image = context.getImageData(0, 0, context.canvas.width, context.canvas.height);
function render(coordinates) {
context.canvas.value = coordinates;
context.clearRect(0, 0, width, height);
context.putImageData(image, 0, 0);
context.beginPath(), path({type: "Point", coordinates}), context.stroke();
}
function render_domain(domain) {
context.clearRect(0, 0, width, height);
context.putImageData(image, 0, 0);
context.beginPath(), path(domain), context.stroke()
}
context.canvas.onmousedown = event => {
mousedown = true;
context.canvas.onmousemove(event);
};
context.canvas.onmousemove = ({layerX, layerY}) => {
if (!mousedown) return;
render(projection.invert([layerX, layerY]));
context.canvas.dispatchEvent(new CustomEvent("input"));
};
context.canvas.onmouseup = event => {
mousedown = false;
};
render([0, 0]);
return Object.assign(context.canvas, {render_domain: render_domain});
}