我正在尝试确定一个点是否在路径内。我尝试过Raphael JS,但正如您在Codepen中所看到的那样,它表明这一点不在路径之内。我读到这一点来确定一个点是否在路径中,通常使用非零或偶数,但这不会检查路径中的每个区域。我想要一种方法来检查路径覆盖的每个区域的每一个。答案可能是canvas或SVG,只要它适用于所有浏览器,它对我来说都没问题。
var paper = Raphael(0, 0, 600, 600);
var p = paper.path("M222,218 L190,174 L203,152 L303,178 L259,216 L187,289 L161,304 L155,237 L215,197 L332,199 L325,164 L239,173 L192,233 L272,294 L351,265 L324,198 L269,199 L200,247 L212,292 L322,309 L366,266 L337,229 L260,249 L192,321 L169,324 L129,249 L131,201 L242,267 L308,294 L356,270 L364,230 L363,216 L222,218 Z");
p.attr('class','cursor');
var arr = [180,250];
var circle = paper.circle(arr[0], arr[1], 1);
console.log(p.isPointInside(arr[0],arr[1])); // returns false, but when I draw a circle at that point, it is clearly inside the path.