length 추가

This commit is contained in:
hyojun.choi 2024-07-04 16:11:23 +09:00
parent e7814a784b
commit 0ba9b9a4e2

View File

@ -20,7 +20,7 @@ export default class QLine extends fabric.Line {
// 선의 길이를 계산하여 length 속성을 초기화합니다.
const dx = this.x2 - this.x1
const dy = this.y2 - this.y1
this.length = Math.sqrt(dx * dx + dy * dy).toFixed(0)
this.length = Number(Math.sqrt(dx * dx + dy * dy).toFixed(0))
this.#viewLengthText = option.viewLengthText ?? true
}
@ -46,7 +46,7 @@ export default class QLine extends fabric.Line {
const dx = this.x2 - this.x1
const dy = this.y2 - this.y1
const length = Math.sqrt(dx * dx + dy * dy)
this.length = length.toFixed(0) // 선의 길이를 length 속성에 저장합니다.
this.length = Number(length.toFixed(0)) // 선의 길이를 length 속성에 저장합니다.
this.#addLengthText()
})
@ -72,7 +72,7 @@ export default class QLine extends fabric.Line {
}
if (this.#viewLengthText) {
const text = new fabric.Text(this.length, {
const text = new fabric.Text(this.length.toString(), {
left: (this.x1 + this.x2) / 2,
top: (this.y1 + this.y2) / 2,
fontSize: this.#fontSize,