canvas 없어도 됨

This commit is contained in:
hyojun.choi 2024-07-16 17:13:27 +09:00
parent a7c0e27f67
commit 15c872e715

View File

@ -25,9 +25,6 @@ export default class QPolygon extends fabric.Group {
if (!options.fontSize) { if (!options.fontSize) {
throw new Error('Font size is required.') throw new Error('Font size is required.')
} }
if (!canvas) {
throw new Error('Canvas is required.')
}
const sortPoints = sortedPoints(points) const sortPoints = sortedPoints(points)
const polygon = new fabric.Polygon(sortPoints, options) const polygon = new fabric.Polygon(sortPoints, options)
@ -647,25 +644,25 @@ export default class QPolygon extends fabric.Group {
const realLine1 = new QLine( const realLine1 = new QLine(
[lines[0].x1, lines[0].y1, vPoint1.x, vPoint1.y], [lines[0].x1, lines[0].y1, vPoint1.x, vPoint1.y],
{ fontSize: this.fontSize, stroke: 'black', strokeWidth: 1 }, { fontSize: this.fontSize, stroke: 'blue', strokeWidth: 1 },
getRoofHypotenuse(lines[0].length / 2), getRoofHypotenuse(lines[0].length / 2),
) )
const realLine2 = new QLine( const realLine2 = new QLine(
[lines[0].x2, lines[0].y2, vPoint1.x, vPoint1.y], [lines[0].x2, lines[0].y2, vPoint1.x, vPoint1.y],
{ fontSize: this.fontSize, stroke: 'black', strokeWidth: 1 }, { fontSize: this.fontSize, stroke: 'blue', strokeWidth: 1 },
getRoofHypotenuse(lines[0].length / 2), getRoofHypotenuse(lines[0].length / 2),
) )
const realLine3 = new QLine( const realLine3 = new QLine(
[lines[1].x1, lines[1].y1, vPoint2.x, vPoint2.y], [lines[1].x1, lines[1].y1, vPoint2.x, vPoint2.y],
{ fontSize: this.fontSize, stroke: 'black', strokeWidth: 1 }, { fontSize: this.fontSize, stroke: 'blue', strokeWidth: 1 },
getRoofHypotenuse(lines[1].length / 2), getRoofHypotenuse(lines[1].length / 2),
) )
const realLine4 = new QLine( const realLine4 = new QLine(
[lines[1].x2, lines[1].y2, vPoint2.x, vPoint2.y], [lines[1].x2, lines[1].y2, vPoint2.x, vPoint2.y],
{ fontSize: this.fontSize, stroke: 'black', strokeWidth: 1 }, { fontSize: this.fontSize, stroke: 'blue', strokeWidth: 1 },
getRoofHypotenuse(lines[1].length / 2), getRoofHypotenuse(lines[1].length / 2),
) )
@ -674,7 +671,7 @@ export default class QPolygon extends fabric.Group {
[vPoint1.x, vPoint1.y, centerPoint1.x, centerPoint1.y], [vPoint1.x, vPoint1.y, centerPoint1.x, centerPoint1.y],
{ {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
strokeDashArray: [5, 5], strokeDashArray: [5, 5],
}, },
@ -686,7 +683,7 @@ export default class QPolygon extends fabric.Group {
[vPoint2.x, vPoint2.y, centerPoint2.x, centerPoint2.y], [vPoint2.x, vPoint2.y, centerPoint2.x, centerPoint2.y],
{ {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
strokeDashArray: [5, 5], strokeDashArray: [5, 5],
}, },
@ -698,7 +695,7 @@ export default class QPolygon extends fabric.Group {
[lines2[0].x2, lines2[0].y2, ridgePoint1[2], ridgePoint1[3]], [lines2[0].x2, lines2[0].y2, ridgePoint1[2], ridgePoint1[3]],
{ {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
}, },
getRoofHypotenuse(lines[0].length / 2), getRoofHypotenuse(lines[0].length / 2),
@ -709,7 +706,7 @@ export default class QPolygon extends fabric.Group {
[lines2[1].x2, lines2[1].y2, ridgePoint2[2], ridgePoint2[3]], [lines2[1].x2, lines2[1].y2, ridgePoint2[2], ridgePoint2[3]],
{ {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
}, },
getRoofHypotenuse(lines[1].length / 2), getRoofHypotenuse(lines[1].length / 2),
@ -718,14 +715,14 @@ export default class QPolygon extends fabric.Group {
// 용마루 // 용마루
const ridge1 = new QLine(ridgePoint1, { const ridge1 = new QLine(ridgePoint1, {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
}) })
// 용마루 // 용마루
const ridge2 = new QLine(ridgePoint2, { const ridge2 = new QLine(ridgePoint2, {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
}) })
@ -733,7 +730,7 @@ export default class QPolygon extends fabric.Group {
[ridgePoint1[2], ridgePoint1[3], ridgePoint2[2], ridgePoint2[3]], [ridgePoint1[2], ridgePoint1[3], ridgePoint2[2], ridgePoint2[3]],
{ {
fontSize: this.fontSize, fontSize: this.fontSize,
stroke: 'black', stroke: 'blue',
strokeWidth: 1, strokeWidth: 1,
}, },
Math.abs(realLine1.length - realLine3.length), Math.abs(realLine1.length - realLine3.length),