From 0119e3fac28e7079cf6be2abd8624183f6e326c8 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 4 Sep 2024 15:43:07 +0900 Subject: [PATCH] =?UTF-8?q?polygon=20scaleX,Y=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20fontSize=20=ED=95=A8=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Roof2.jsx | 3 +++ src/components/fabric/QPolygon.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 2d275a36..70deec93 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -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() } diff --git a/src/components/fabric/QPolygon.js b/src/components/fabric/QPolygon.js index a3329ac5..0c503185 100644 --- a/src/components/fabric/QPolygon.js +++ b/src/components/fabric/QPolygon.js @@ -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) },