Open
Description
The current isPointInsidePath()
implementation launches an horizontal ray and counts how many times it intersects the path. However it relies on interHelper()
which has trouble finding intersections lying exactly at path vertex coordinates. This causes the issue reported in #563 that #594 attempted to fix.
Here is an example of an obvious failure:
var shape = paper.path("M0,80 L80,0 L160,80 L80,160 Z");
Raphael.isPointInsidePath(shape.getPath(), 80, 80);
>>> false
Obviously interHelper()
needs fixing, but because that is a complex task I suggest instead to add some jitter to the ray destination in isPointInsidePath()
, which is trivial and harmless. Instead of:
interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;
Use:
interPathHelper(path, [["M", x, y], ["l", bbox.width + 10, Math.random()]], 1) % 2 == 1;
Metadata
Assignees
Labels
No labels