From b362ba8b6371a5eb113d07b5f18c2912d330a1a4 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Tue, 29 Oct 2024 10:13:16 +0900 Subject: [PATCH] =?UTF-8?q?line=20to=20polygon=EC=8B=9C=20=EA=B8=B8?= =?UTF-8?q?=EC=9D=B4=20=EC=95=88=EB=A7=9E=EB=8A=94=20=ED=98=84=EC=83=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QLine.js | 4 +--- src/components/fabric/QPolygon.js | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/fabric/QLine.js b/src/components/fabric/QLine.js index 4ee9535a..86a96845 100644 --- a/src/components/fabric/QLine.js +++ b/src/components/fabric/QLine.js @@ -21,9 +21,7 @@ export const QLine = fabric.util.createClass(fabric.Line, { } this.line = this // 소수점 전부 제거 - points.forEach((point) => { - point = Math.round(point) - }) + points = points.map((point) => Math.round(point)) this.idx = options.idx ?? 0 this.direction = options.direction ?? getDirectionByPoint({ x: this.x1, y: this.y1 }, { x: this.x2, y: this.y2 }) diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index 8068a772..decc99ae 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -24,8 +24,8 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { initialize: function (points, options, canvas) { // 소수점 전부 제거 points.forEach((point) => { - point.x = Math.round(point.x) - point.y = Math.round(point.y) + point.x = Number(point.x.toFixed(1)) + point.y = Number(point.y.toFixed(1)) }) options.selectable = options.selectable ?? true options.sort = options.sort ?? true