1

split polygon by lineArea

I want to drag LineArea to split polygon continuously with Konva. If lineArea is a Konva.Shape. I can use following procedure to split polygon:

let prePt
lineArea.on("dragstart",function(){
   prePt = this.getAbsolutePosition();
});
lineArea.on("dragmove",function(){
   let curPt = this.getAbsolutePosition();
   move split line denoted by lineArea;
   split polygon by line
});

but how can I change lineArea's shape in dragmove event? or any improved solution is appreciated;

wiky win
  • 13
  • 3

1 Answers1

1

If I am getting this right, you want to create a kind of »sweep line« effect, such that the »lineArea« will be the intersection of the polygon and a rotated rectangle.

However, a general solution would be exactly that: The intersection of two polygons, since the rectangle/lineArea can be treated as a polygon as well. Have a look that this question, since it lists libraries that support boolean operations, whereby an intersection is one of them is paperjs.

How to compute such an Intersection is far beyond the scope of such an answer here and since this has been done already, i would recommend you to use an existing library.

philipp
  • 15,947
  • 15
  • 61
  • 106