From 88b73eb91ec11a78ed1c4fb053c892509c262866 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 11 Jul 2024 17:42:45 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Roof2.jsx | 18 +++++++++--------- src/components/fabric/QPolygon.js | 12 ++++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 9e8f55ff..3dbfc5c7 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -135,8 +135,8 @@ export default function Roof2() { const makeQPolygon = () => { const type1 = [ { x: 100, y: 100 }, - { x: 800, y: 100 }, - { x: 800, y: 800 }, + { x: 850, y: 100 }, + { x: 850, y: 800 }, { x: 500, y: 800 }, { x: 500, y: 400 }, { x: 100, y: 400 }, @@ -160,16 +160,16 @@ export default function Roof2() { ] const type4 = [ - { x: 153.96209743461895, y: 446.46989831140326 }, - { x: 153.96209743461895, y: 796.879061239893 }, - { x: 754.3712603631087, y: 796.879061239893 }, - { x: 754.3712603631087, y: 196.46989831140326 }, - { x: 403.962097434619, y: 196.46989831140326 }, - { x: 403.962097434619, y: 446.46989831140326 }, + { x: 150, y: 450 }, + { x: 150, y: 800 }, + { x: 750, y: 800 }, + { x: 750, y: 300 }, + { x: 550, y: 300 }, + { x: 550, y: 450 }, ] if (canvas) { const polygon = new QPolygon( - type3, + type1, { fill: 'transparent', stroke: 'black', diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index 7fbe9d4a..a2a78fda 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -30,7 +30,6 @@ export default class QPolygon extends fabric.Group { } const sortPoints = sortedPoints(points) - console.log(sortPoints) const polygon = new fabric.Polygon(sortPoints, options) super([polygon], {}) @@ -321,7 +320,9 @@ export default class QPolygon extends fabric.Group { return } //외각선 기준 - const topIndex = findTopTwoIndexesByDistance(this.lines) //배열중에 큰 2값을 가져옴 TODO: 나중에는 인자로 받아서 다각으로 수정 해야됨 + const topIndex = findTopTwoIndexesByDistance(this.lines).sort( + (a, b) => a - b, + ) //배열중에 큰 2값을 가져옴 TODO: 나중에는 인자로 받아서 다각으로 수정 해야됨 //일단 배열 6개 짜리 기준의 선 번호 if (topIndex[0] === 4) { @@ -639,7 +640,7 @@ export default class QPolygon extends fabric.Group { y: (lines[1].y1 + lines[1].y2) / 2, } - ridgeLength = Math.min(this.lines[2].length, this.lines[5].length) + ridgeLength = Math.min(this.lines[4].length, this.lines[5].length) ridgePoint1 = [vPoint1.x, vPoint1.y, vPoint1.x + ridgeLength, vPoint1.y] ridgePoint2 = [vPoint2.x, vPoint2.y, vPoint2.x, vPoint2.y + ridgeLength] } @@ -694,7 +695,7 @@ export default class QPolygon extends fabric.Group { // 용마루 보조선 const ridgeHelpLine1 = new QLine( - [lines2[1].x2, lines2[1].y2, ridgePoint1[2], ridgePoint1[3]], + [lines2[0].x2, lines2[0].y2, ridgePoint1[2], ridgePoint1[3]], { fontSize: this.fontSize, stroke: 'black', @@ -705,7 +706,7 @@ export default class QPolygon extends fabric.Group { // 용마루 보조선 const ridgeHelpLine2 = new QLine( - [lines2[0].x2, lines2[0].y2, ridgePoint2[2], ridgePoint2[3]], + [lines2[1].x2, lines2[1].y2, ridgePoint2[2], ridgePoint2[3]], { fontSize: this.fontSize, stroke: 'black', @@ -751,7 +752,6 @@ export default class QPolygon extends fabric.Group { this.addWithUpdate(ridgeEndLine) this.canvas.renderAll() - console.log(JSON.stringify(this.points)) } #drawHelpLineInOctagon(chon) {}