버그 수정
This commit is contained in:
parent
e72b7b84f8
commit
051ea87861
@ -12,6 +12,7 @@ export class QLine extends fabric.Group {
|
|||||||
direction
|
direction
|
||||||
type = 'QLine'
|
type = 'QLine'
|
||||||
parent
|
parent
|
||||||
|
#lengthTxt = 0
|
||||||
|
|
||||||
constructor(points, option, lengthTxt) {
|
constructor(points, option, lengthTxt) {
|
||||||
const [x1, y1, x2, y2] = points
|
const [x1, y1, x2, y2] = points
|
||||||
@ -33,7 +34,7 @@ export class QLine extends fabric.Group {
|
|||||||
this.parent = option.parent
|
this.parent = option.parent
|
||||||
|
|
||||||
if (lengthTxt > 0) {
|
if (lengthTxt > 0) {
|
||||||
this.length = Number(lengthTxt)
|
this.#lengthTxt = Number(lengthTxt)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#init()
|
this.#init()
|
||||||
@ -41,20 +42,16 @@ export class QLine extends fabric.Group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#init() {
|
#init() {
|
||||||
this.#addLengthText()
|
this.#addLengthText(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
#addControl() {
|
#addControl() {
|
||||||
this.on('added', () => {
|
|
||||||
this.#addLengthText()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.on('moving', () => {
|
this.on('moving', () => {
|
||||||
this.#addLengthText()
|
this.#addLengthText(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.on('modified', (e) => {
|
this.on('modified', (e) => {
|
||||||
this.#addLengthText()
|
this.#addLengthText(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.on('selected', () => {
|
this.on('selected', () => {
|
||||||
@ -66,21 +63,24 @@ export class QLine extends fabric.Group {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#addLengthText() {
|
#addLengthText(isFirst) {
|
||||||
if (this.text) {
|
if (this.text) {
|
||||||
this.removeWithUpdate(this.text)
|
this.removeWithUpdate(this.text)
|
||||||
this.text = null
|
this.text = null
|
||||||
}
|
}
|
||||||
if (this.length > 0) {
|
|
||||||
const text = new fabric.Textbox(this.length.toFixed(0).toString(), {
|
if (isFirst && this.#lengthTxt > 0) {
|
||||||
|
const text = new fabric.Textbox(this.#lengthTxt.toFixed(0).toString(), {
|
||||||
left: (this.x1 + this.x2) / 2,
|
left: (this.x1 + this.x2) / 2,
|
||||||
top: (this.y1 + this.y2) / 2,
|
top: (this.y1 + this.y2) / 2,
|
||||||
fontSize: this.fontSize,
|
fontSize: this.fontSize,
|
||||||
})
|
})
|
||||||
|
this.length = this.#lengthTxt
|
||||||
this.text = text
|
this.text = text
|
||||||
this.addWithUpdate(text)
|
this.addWithUpdate(text)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const scaleX = this.scaleX
|
const scaleX = this.scaleX
|
||||||
const scaleY = this.scaleY
|
const scaleY = this.scaleY
|
||||||
const x1 = this.left
|
const x1 = this.left
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
import { fabric } from 'fabric'
|
import { fabric } from 'fabric'
|
||||||
import {
|
import {
|
||||||
calculateIntersection,
|
|
||||||
distanceBetweenPoints,
|
distanceBetweenPoints,
|
||||||
getDegreeByChon,
|
getDegreeByChon,
|
||||||
getDirection,
|
|
||||||
getDirectionByPoint,
|
getDirectionByPoint,
|
||||||
getRoofHeight,
|
getRoofHeight,
|
||||||
getRoofHypotenuse,
|
getRoofHypotenuse,
|
||||||
@ -81,6 +79,13 @@ export default class QPolygon extends fabric.Group {
|
|||||||
this.texts.forEach((text) => {
|
this.texts.forEach((text) => {
|
||||||
text.set({ fontSize })
|
text.set({ fontSize })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.getObjects().forEach((obj) => {
|
||||||
|
if (obj.type === 'QLine') {
|
||||||
|
obj.setFontSize(fontSize)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.addWithUpdate()
|
this.addWithUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,9 +309,14 @@ export default class QPolygon extends fabric.Group {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const smallestLines = this.lines.filter(
|
// QPolygon 객체의 모든 선들을 가져옵니다.
|
||||||
(line) => line.length === smallestLength,
|
const lines = [...this.lines]
|
||||||
)
|
|
||||||
|
// 이 선들을 길이에 따라 정렬합니다.
|
||||||
|
lines.sort((a, b) => a.length - b.length)
|
||||||
|
|
||||||
|
// 정렬된 배열에서 가장 작은 두 선을 선택합니다.
|
||||||
|
const smallestLines = lines.slice(0, 2)
|
||||||
|
|
||||||
let needPlusLine
|
let needPlusLine
|
||||||
let needMinusLine
|
let needMinusLine
|
||||||
@ -448,6 +458,6 @@ export default class QPolygon extends fabric.Group {
|
|||||||
this.addWithUpdate(realLine4)
|
this.addWithUpdate(realLine4)
|
||||||
this.addWithUpdate(realLine5)
|
this.addWithUpdate(realLine5)
|
||||||
this.addWithUpdate(realLine6)
|
this.addWithUpdate(realLine6)
|
||||||
this.addWithUpdate(ridge)
|
this.canvas.add(ridge)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user