Q컴포넌트 생성시 폰트사이즈는 필수
This commit is contained in:
parent
3d7d2ab0dc
commit
2e3a933dbb
@ -100,11 +100,11 @@ export default function Roof2() {
|
|||||||
|
|
||||||
setCanvasSize(() => ({
|
setCanvasSize(() => ({
|
||||||
vertical: verticalSize,
|
vertical: verticalSize,
|
||||||
horizontal: horizontalSize
|
horizontal: horizontalSize,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 값 변경시
|
* 값 변경시
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -5,9 +5,13 @@ export default class QLine extends fabric.Line {
|
|||||||
#text
|
#text
|
||||||
#viewLengthText
|
#viewLengthText
|
||||||
#fontSize
|
#fontSize
|
||||||
|
type = 'QLine'
|
||||||
constructor(points, option) {
|
constructor(points, option) {
|
||||||
|
if (option.fontSize) {
|
||||||
|
throw new Error('Font size is required.')
|
||||||
|
}
|
||||||
super(points, option)
|
super(points, option)
|
||||||
this.#fontSize = option.fontSize ?? 16
|
this.#fontSize = option.fontSize
|
||||||
this.#init(option)
|
this.#init(option)
|
||||||
this.#addControl()
|
this.#addControl()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,10 +4,14 @@ export default class QPolygon extends fabric.Polygon {
|
|||||||
#viewLengthText
|
#viewLengthText
|
||||||
#text = []
|
#text = []
|
||||||
#fontSize
|
#fontSize
|
||||||
|
type = 'QPolygon'
|
||||||
|
|
||||||
constructor(points, option) {
|
constructor(points, option) {
|
||||||
|
if (option.fontSize) {
|
||||||
|
throw new Error('Font size is required.')
|
||||||
|
}
|
||||||
super(points, option)
|
super(points, option)
|
||||||
this.#fontSize = option.fontSize ?? 16
|
this.#fontSize = option.fontSize
|
||||||
this.#init(points)
|
this.#init(points)
|
||||||
this.#addControl()
|
this.#addControl()
|
||||||
}
|
}
|
||||||
@ -48,6 +52,14 @@ export default class QPolygon extends fabric.Polygon {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTexts(texts) {
|
||||||
|
this.#text = texts
|
||||||
|
}
|
||||||
|
|
||||||
|
getTexts() {
|
||||||
|
return this.#text
|
||||||
|
}
|
||||||
|
|
||||||
#addLengthText() {
|
#addLengthText() {
|
||||||
if (this.#text.length > 0) {
|
if (this.#text.length > 0) {
|
||||||
this.#text.forEach((text) => {
|
this.#text.forEach((text) => {
|
||||||
|
|||||||
@ -3,15 +3,19 @@ export default class QRect extends fabric.Rect {
|
|||||||
#text = []
|
#text = []
|
||||||
#viewLengthText
|
#viewLengthText
|
||||||
#fontSize
|
#fontSize
|
||||||
constructor(points, option) {
|
type = 'QRect'
|
||||||
super(points, option)
|
constructor(option) {
|
||||||
this.#fontSize = points.fontSize ?? 16
|
if (option.fontSize) {
|
||||||
this.#init(points)
|
throw new Error('Font size is required.')
|
||||||
|
}
|
||||||
|
super(option)
|
||||||
|
this.#fontSize = option.fontSize
|
||||||
|
this.#init(option)
|
||||||
this.#addControl()
|
this.#addControl()
|
||||||
}
|
}
|
||||||
|
|
||||||
#init(points) {
|
#init(option) {
|
||||||
this.#viewLengthText = points.viewLengthText ?? true
|
this.#viewLengthText = option.viewLengthText ?? true
|
||||||
}
|
}
|
||||||
|
|
||||||
setViewLengthText(bool) {
|
setViewLengthText(bool) {
|
||||||
@ -79,7 +83,7 @@ export default class QRect extends fabric.Rect {
|
|||||||
const text = new fabric.Text(length.toFixed(0), {
|
const text = new fabric.Text(length.toFixed(0), {
|
||||||
left: (line.start.x + line.end.x) / 2,
|
left: (line.start.x + line.end.x) / 2,
|
||||||
top: (line.start.y + line.end.y) / 2,
|
top: (line.start.y + line.end.y) / 2,
|
||||||
fontSize: this.#fontSize,
|
fontSize: this.fontSize,
|
||||||
selectable: false,
|
selectable: false,
|
||||||
})
|
})
|
||||||
this.#text.push(text)
|
this.#text.push(text)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user