Skip to content

Instantly share code, notes, and snippets.

@penguinbroker
Created November 19, 2011 01:15
Show Gist options
  • Save penguinbroker/1378258 to your computer and use it in GitHub Desktop.
Save penguinbroker/1378258 to your computer and use it in GitHub Desktop.
Paper.js hit test
hitTool = new paper.Tool();
hitTool.activate();
hitTool.onMouseDown = function (event) {
hitOptions = {
segments: true,
stroke: true,
fill: true,
tolerance: 5
};
hitResult = paper.project.hitTest(event.point, hitOptions);
if (hitResult) {
// we have a hit, do something here
hitResult.item.selected = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment