polygon scaleX,Y 추가 및 fontSize 함수 수정

This commit is contained in:
hyojun.choi 2024-09-04 15:43:07 +09:00
parent 566de9b290
commit 0119e3fac2
2 changed files with 17 additions and 1 deletions

View File

@ -596,10 +596,13 @@ export default function Roof2(props) {
const changeLength = (e) => {
setScale(e)
const polygon = canvas?.getActiveObject()
if (polygon.type !== 'QPolygon') {
return
}
polygon.setScaleX(e)
canvas?.renderAll()
}

View File

@ -213,7 +213,12 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
},
setFontSize(fontSize) {
this.fontSize = fontSize
this.text.set({ fontSize })
this.canvas
?.getObjects()
.filter((obj) => obj.name === 'lengthText' && obj.parent === this)
.forEach((text) => {
text.set({ fontSize: fontSize })
})
},
_render: function (ctx) {
this.callSuper('_render', ctx)
@ -700,6 +705,14 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
text.set({ visible: isView })
})
},
setScaleX(scale) {
this.scaleX = scale
this.addLengthText()
},
setScaleY(scale) {
this.scaleY = scale
this.addLengthText()
},
divideLine() {
splitPolygonWithLines(this)
},