fabricjs에서 Polygon개체가 서로 교차하는지 알아보기

catch me if u can!·2021년 3월 5일
0

fabric.js is a powerful and simple Javascript HTML5 canvas library
fabricjs에서 Polygon좌표를 절대값으로 변환하기 - convertAbsolutePoint()

두 Polygon개체가 교차하는지 여부를 반환한다. 교차할 경우 교차하는 points정보를 반환한다.

var canvas = new fabric.Canvas("canvas");
var [area1, area2] = canvas.getActiveObject();
var intersect = fabric.Intersection.intersectPolygonPolygon(convertAbsolutePoint(area1), convertAbsolutePoint(area2)); 
//교차점이 없는 경우 {"points":[]}
//교차점이 있는 경우 {"status":"Intersection","points":[{"x":100,"y":80},{"x":76,"y":100}]}
profile
마쿠투소케 난쿠로나이사

0개의 댓글