Skip to content

Instantly share code, notes, and snippets.

@cestella
cestella / README.md
Last active August 29, 2015 14:01 — forked from weiglemc/.block
@cestella
cestella / README.md
Last active August 29, 2015 14:01 — forked from GerHobbelt/README.md

Here's a d3 plugin that allows you to create a polygon selection. You instantiate it just like d3.svg.brush.

var brush = d3.svg.polybrush();

It has an extra public method that 'brush' does not, and that's 'isWithinExtent(x, y)'. You can use this method to test if a given point falls within the drawn extent.

if (brush.isWithinExtent(x, y)) {
  console.log("I'm inside!");
}
@cestella
cestella / README.md
Last active August 29, 2015 14:00 — forked from lgersman/README.md
  • Click into the drawing area to start the selection frame
  • move the mouse to resize the selection frame
  • Release the mouse button to resize the selection frame

(The circles are just for illustrating purposes)