function chart() {
const context = DOM.context2d(width, height),
canvas = context.canvas;
const paintPoints = d3.line().context(context);
function draw() {
context.fillStyle = "#fefef2";
context.fillRect(0, 0, width, height);
context.lineWidth = 0.25;
const found = findInPolygonMark(quadtree, polygon),
{ tested, visited, rejected, accepted, time } = found;
context.fillStyle = "#eee";
accepted.forEach(({ x1, y1, x2, y2 }) =>
context.fillRect(x1, y1, x2 - x1, y2 - y1)
);
context.fillStyle = "#ffffff";
rejected.forEach(({ x1, y1, x2, y2 }) =>
context.fillRect(x1, y1, x2 - x1, y2 - y1)
);
context.strokeStyle = "#000";
visited.forEach(({ x1, y1, x2, y2 }) =>
context.strokeRect(x1, y1, x2 - x1, y2 - y1)
);
context.fillStyle = "#aaa";
context.beginPath();
paintPoints.curve(curvePoints(1.5))(data);
context.fill();
context.fillStyle = "steelblue";
context.beginPath();
paintPoints.curve(curvePoints(2.5))(tested);
context.fill();
context.fillStyle = "#333";
context.beginPath();
paintPoints.curve(curvePoints(2.5))(found);
context.fill();
context.lineWidth = 1.5;
context.strokeStyle = "orange";
context.stroke(new Path2D(`M${polygon.flat()}Z`));
context.fillStyle = "orange";
context.beginPath();
paintPoints.curve(curvePoints(5))(polygon);
context.fill();
context.fillStyle = "#000";
context.fillText(time, 10, height-10)
}
return d3
.select(canvas)
.call(draw)
.on("mousemove", function() {
const m = d3.mouse(this);
d3.select(canvas).style(
"cursor",
d3.min(polygon, p => distance(p, m)) < 10 ? "grab" : "crosshair"
);
})
.call(drag(polygon, draw))
.node();
}