KonvaJs:拖动时更改线点
KonvaJs: Change points of line when dragged
我正在使用 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。
拖动 Konva 将更改 {x,y}
节点(圆形、矩形、直线等)的属性。您只需要将 x
和 y
添加到 points
:
vs.push({
x: points[i] + poly.x(),
y: points[i + 1] + poly.y()
});
我正在使用 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。
拖动 Konva 将更改 {x,y}
节点(圆形、矩形、直线等)的属性。您只需要将 x
和 y
添加到 points
:
vs.push({
x: points[i] + poly.x(),
y: points[i + 1] + poly.y()
});