Detecting wether a point is inside or outside of a raphael.js shape

后端 未结 3 597
一向
一向 2021-01-06 16:52

I have a raphael.js shape which I am plotting circle\'s on top of. I only want a circle to appear if the circle does not go off the boundary of the shape it is being plotted

3条回答
  •  借酒劲吻你
    2021-01-06 17:16

    One possible way to dertermine if a point is inside closed path is this:

    1. Choose coordinates that are definitely outside the shape.
    2. Make a line from that point to your actual point in question.
    3. Count, how often the line intersects with the path.
    4. if the number of intersections is odd, then your point is inside. If it's even, the point is outside.

    I don't know if that help you very much since I don't know raphael.js at all. But it's a working geometrical approach to the problem.

提交回复
热议问题