block by plmrry 5c41b49ac8b3a4925dd23a2c9c00bd98

Line Hovering With Point Sampling

Full Screen

Voronoi diagrams are often used to highlight nearby points based on mouse position.

However, the Voronoi will not always work as intended when working with paths.

Try hovering over the middle of the red path — although the mouse is closer to the red path, the blue line is highlighted.

We can fix this problem by sampling points along the path (similar to the technique used here), and adding these sampled points to the Voronoi mesh.

script.js

index.html