From 5d7cec520bfdda6313772c944c4e83562a27a9eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=BF=97=E9=B9=8F?= <2916022834@qq.com> Date: Mon, 2 Feb 2026 11:33:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E9=93=BA=E9=BB=98=E8=AE=A4=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commands/FillRepeatCommand.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js b/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js index dc82f0e2..3c97e52b 100644 --- a/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js +++ b/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js @@ -109,12 +109,19 @@ export class FillRepeatCommand extends Command { const fdObject = this.canvasManager.getFixedLayerObject(); const bgObject = this.canvasManager.getBackgroundLayerObject(); const tObject = fdObject || bgObject; + const tWidth = tObject.width; + const tHeight = tObject.height; + // const offsetX = object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : tObject.width / 2; // const offsetY = object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : tObject.height / 2; - const patternTransform = object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(0.3, 0); + const scaleX_ = tWidth / img.width / 5; + const scaleY_ = tHeight / img.height / 5; + const scale_ = tWidth > tHeight ? scaleX_ : scaleY_; + + const patternTransform = object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(scale_, 0); const scale = getTransformScaleAngle(patternTransform).scale; - const offsetX = tObject.width / 2 - img.width * scale / 2; - const offsetY = tObject.height / 2 - img.height * scale / 2; + const offsetX = tWidth / 2 - img.width * scale / 2; + const offsetY = tHeight / 2 - img.height * scale / 2; const pattern = new fabric.Pattern({ source: img, repeat: this.fillRepeat, @@ -146,10 +153,10 @@ export class FillRepeatCommand extends Command { let scaleX = tObject.scaleX || 1; let scaleY = tObject.scaleY || 1; rect.set({ - width: tObject.width, - height: tObject.height, - top: tObject.top - tObject.height * scaleY / 2, - left: tObject.left - tObject.width * scaleX / 2, + width: tWidth, + height: tHeight, + top: tObject.top - tHeight * scaleY / 2, + left: tObject.left - tWidth * scaleX / 2, scaleX, scaleY, }); @@ -192,7 +199,7 @@ export class FillRepeatCommand extends Command { // 复制原对象的属性 copyObjectProperties(object) { - return{ + return { id: object.id, layerId: object.layerId, layerName: object.layerName,