length 속성 추가
This commit is contained in:
parent
7649655b17
commit
e7814a784b
@ -1,7 +1,7 @@
|
||||
import { fabric } from 'fabric'
|
||||
|
||||
export default class QLine extends fabric.Line {
|
||||
#length
|
||||
length
|
||||
#text
|
||||
#viewLengthText
|
||||
#fontSize
|
||||
@ -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 = 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 = 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, {
|
||||
left: (this.x1 + this.x2) / 2,
|
||||
top: (this.y1 + this.y2) / 2,
|
||||
fontSize: this.#fontSize,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user