I am using KonvaJs in my project. I am creating a polygon using Konva.Line
by setting closed:true
. I need to figure out that whether a point is inside the polygon or not. I am using Ray-Casting algorithm to find point in polygon and it's working fine. But the problem arises when polygon is dragged. When it is dragged the vertices(points) still remains the same and because of that I am not able to get the new coordinates. How can I change the points of polygon so that I can use them? Here's the plunkr.
While dragging Konva will change {x,y}
properties of Node (Circle, Rect, Line, etc). All you need is to add x
and y
to points
:
vs.push({
x: points[i] + poly.x(),
y: points[i + 1] + poly.y()
});