Skip to content

Instantly share code, notes, and snippets.

View taktran's full-sized avatar

Tak Tran taktran

View GitHub Profile
@taktran
taktran / README.md
Last active December 23, 2015 18:49 — forked from couchand/README.md
Force layout + voronoi tesselation

Adapted from couchand/6420534 for demostration purposes.


Object selection is tough, particularly when the things you'd like to select are moving around (like nodes in a force-directed layout, perhaps). Allowing a user the fudge factor of an area cursor helps, but can get in the way when targets are small enough. The use of a Voronoi tessellation promises a map of closest node for any given point.

This example illustrates the use of a Voronoi overlay to clip nodes in a force-directed simulation. By using the Voronoi shapes as the clipping path the nodes themselves can be drawn much simpler.

This builds on these two examples from Mike Bostock on force-directed graphs and voronoi tesselation, as well as Nate Vack's Voronoi selection example here and this first pass at an integration from Christop