g.js icon indicating copy to clipboard operation
g.js copied to clipboard

hit detection

Open davidm-public opened this issue 8 years ago • 2 comments

hi, nice library, wondering if it's possible to do hit detection on a shape, ie: to know which shape the mouse is over?

thanks

davidm-public avatar Oct 22 '17 18:10 davidm-public

Yes, a Path object has a .contains method that takes an x/y argument. This also works on a Group.

fdb avatar Oct 22 '17 18:10 fdb

Here's the source:

https://github.com/nodebox/g.js/blob/88c9deaba4d57855915264dec4bcf8054b230f17/src/libraries/vg/objects/path.js#L396

fdb avatar Oct 22 '17 18:10 fdb