From a663faf359f95cb1437a5afb255b31e498f8050d Mon Sep 17 00:00:00 2001 From: ysCha Date: Wed, 20 Aug 2025 18:28:47 +0900 Subject: [PATCH] =?UTF-8?q?[1267]=20500=EC=97=90=EB=9F=AC=20-=20str=20=3D>?= =?UTF-8?q?=20Number=20=EB=B3=80=ED=99=98=20(=EC=9D=B4=EC=A0=84=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=B5=EA=B5=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QLine.js | 2 +- src/components/fabric/QPolygon.js | 12 ++++++------ src/util/canvas-util.js | 8 -------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/components/fabric/QLine.js b/src/components/fabric/QLine.js index 48680343..af9dd7a4 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 e1c80f4d..b50cdaa3 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 dc3b3c93..0af492a1 100644 --- a/src/util/canvas-util.js +++ b/src/util/canvas-util.js @@ -342,14 +342,6 @@ 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