All examples By author By category About

plmrry

Line Hovering With Point Sampling

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.