Question

In the paper.js framework the following code performs a hit test on the point of a mouse coordinate.

function onMouseUp(event) 
{
var hitOptions = {
stroke: false,
fill: true,
tolerance: 2

};  
var hitResult = project.hitTest(event.point, hitOptions);
}

What I would like to do is to perform this test within a given radius of the event.point() but I haven't found a way yet.

Any ideas?

UPDATE

I think the way I was setting the options caused tolerance to be ignored. The following code works:

var hitOptions = {
fill: true, 
stroke: true, 
segments: true, 
tolerance: 200 
};  
var hitResult = project.hitTest(event.point, hitOptions);
alert(hitResult);
Was it helpful?

Solution

It looks like the tolerance options isn't read due to a bug. You can manually change the tolerance by modifying line 3631 (in the nightly). For example, if you want a test radius of 200 points:

tolerance: paper.project.options.hitTolerance || 2

to:

tolerance: paper.project.options.hitTolerance || 200
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top