From ba590c4f9f618fb6f721fd76168603ded5a72a03 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 31 Jul 2024 10:13:11 +0900 Subject: [PATCH] =?UTF-8?q?Qpolygon=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/fabric/QPolygon.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index b5978bfb..da256f70 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -1,8 +1,8 @@ import { fabric } from 'fabric' import { v4 as uuidv4 } from 'uuid' import { QLine } from '@/components/fabric/QLine' -import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPoints } from '@/util/canvas-util' -import { drawHelpLineInHexagon } from '@/util/qpolygon-utils' +import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util' +import { drawHelpLineInHexagon, drawHelpLineInHexagon2, drawHelpLineInHexagon3 } from '@/util/qpolygon-utils' export const QPolygon = fabric.util.createClass(fabric.Polygon, { type: 'QPolygon', @@ -16,7 +16,12 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { point.x = Math.round(point.x) point.y = Math.round(point.y) }) - points = sortedPoints(points) + if (points.length <= 8) { + points = sortedPointLessEightPoint(points) + } else { + points = sortedPoints(points) + } + this.callSuper('initialize', points, options) if (options.id) { this.id = options.id @@ -117,11 +122,11 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, { // 보조선 그리기 drawHelpLine(chon = 4) { - drawHelpLineInHexagon(this, chon) + drawHelpLineInHexagon2(this, chon) }, addLengthText() { - const points = this.getCurrentPoints() + let points = this.points points.forEach((start, i) => { const thisText = this.canvas.getObjects().find((obj) => obj.name === 'lengthText' && obj.parentId === this.id && obj.idx === i)