diff --git a/src/components/fabric/QLine.js b/src/components/fabric/QLine.js index af9dd7a4..48680343 100644 --- a/src/components/fabric/QLine.js +++ b/src/components/fabric/QLine.js @@ -17,7 +17,7 @@ export const QLine = fabric.util.createClass(fabric.Line, { initialize: function (points, options, length = 0) { // 소수점 전부 제거 - points = points.map((point) => Number(point?.toFixed(1))) + points = points.map((point) => Number(point).toFixed(1)) this.callSuper('initialize', points, { ...options, selectable: options.selectable ?? true }) if (options.id) { diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index b50cdaa3..e1c80f4d 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -710,14 +710,14 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { inPolygonImproved(point) { const vertices = this.points let inside = false - const testX = Number(point.x.toFixed(this.toFixed)) - const testY = Number(point.y.toFixed(this.toFixed)) + const testX = Number(point.x).toFixed(this.toFixed) + const testY = Number(point.y).toFixed(this.toFixed) for (let i = 0, j = vertices.length - 1; i < vertices.length; j = i++) { - const xi = Number(vertices[i].x.toFixed(this.toFixed)) - const yi = Number(vertices[i].y.toFixed(this.toFixed)) - const xj = Number(vertices[j].x.toFixed(this.toFixed)) - const yj = Number(vertices[j].y.toFixed(this.toFixed)) + const xi = Number(vertices[i].x).toFixed(this.toFixed) + const yi = Number(vertices[i].y).toFixed(this.toFixed) + const xj = Number(vertices[j].x).toFixed(this.toFixed) + const yj = Number(vertices[j].y).toFixed(this.toFixed) // 점이 정점 위에 있는지 확인 if (Math.abs(xi - testX) < 0.01 && Math.abs(yi - testY) < 0.01) { diff --git a/src/util/canvas-util.js b/src/util/canvas-util.js index 0af492a1..dc3b3c93 100644 --- a/src/util/canvas-util.js +++ b/src/util/canvas-util.js @@ -342,6 +342,14 @@ export const findIntersection1 = (line1, line2) => { } export const calculateIntersection = (line1, line2) => { + line1.x1 = Number(line1.x1) + line1.y1 = Number(line1.y1) + line1.x2 = Number(line1.x2) + line1.y2 = Number(line1.y2) + line2.x1 = Number(line2.x1) + line2.y1 = Number(line2.y1) + line2.x2 = Number(line2.x2) + line2.y2 = Number(line2.y2) const result = intersect([line1.x1, line1.y1], [line1.x2, line1.y2], [line2.x1, line2.y1], [line2.x2, line2.y2]) if (!result) { return null