diff --git a/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js b/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js index b8e0baee..85aa2dd6 100644 --- a/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js +++ b/src/component/Canvas/CanvasEditor/commands/FillRepeatCommand.js @@ -110,13 +110,15 @@ export class FillRepeatCommand extends Command { height: object.height, } }; + const fdObject = this.canvasManager.getFixedLayerObject(); const bgObject = this.canvasManager.getBackgroundLayerObject(); + const tObject = fdObject || bgObject; const pattern = new fabric.Pattern({ source: img, repeat: this.fillRepeat, patternTransform: object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(scale, 0), - offsetX: object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : bgObject.width / 2, // 水平偏移 - offsetY: object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : bgObject.height / 2, // 垂直偏移 + offsetX: object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : tObject.width / 2, // 水平偏移 + offsetY: object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : tObject.height / 2, // 垂直偏移 }); const rect = new fabric.Rect({ id: object.id, @@ -143,13 +145,13 @@ export class FillRepeatCommand extends Command { flipY: object.flipY, }); } else { - let scaleX = bgObject.scaleX || 1; - let scaleY = bgObject.scaleY || 1; + let scaleX = tObject.scaleX || 1; + let scaleY = tObject.scaleY || 1; rect.set({ - width: bgObject.width, - height: bgObject.height, - top: bgObject.top - bgObject.height * scaleY / 2, - left: bgObject.left - bgObject.width * scaleX / 2, + width: tObject.width, + height: tObject.height, + top: tObject.top - tObject.height * scaleY / 2, + left: tObject.left - tObject.width * scaleX / 2, scaleX, scaleY, }); @@ -305,6 +307,7 @@ export class FillRepeatGapChangeCommand extends Command { object.fill_.gapY = this.newGapY; } const image = new Image(); + image.crossOrigin = "anonymous"; image.src = object.fill_.source; await image.decode(); object.fill_.width = image.width; diff --git a/src/component/Canvas/CanvasEditor/components/SelectMenuPanel/index.vue b/src/component/Canvas/CanvasEditor/components/SelectMenuPanel/index.vue index 84659f21..2ac1bfc6 100644 --- a/src/component/Canvas/CanvasEditor/components/SelectMenuPanel/index.vue +++ b/src/component/Canvas/CanvasEditor/components/SelectMenuPanel/index.vue @@ -125,6 +125,7 @@ " :options="selectOptions" @change="(e) => changeFillRepeat(e, v)" + :disabled="v.layer?.metadata?.level2Type === 'Embroidery'" /> diff --git a/src/component/Canvas/CanvasEditor/managers/CanvasManager.js b/src/component/Canvas/CanvasEditor/managers/CanvasManager.js index 9c7bb1cc..1aa12934 100644 --- a/src/component/Canvas/CanvasEditor/managers/CanvasManager.js +++ b/src/component/Canvas/CanvasEditor/managers/CanvasManager.js @@ -1187,7 +1187,8 @@ export class CanvasManager { obj.scale = [scaleXY, scaleXY]; obj.angle = angle; obj.location = [left, top]; - obj.gap = [fill_.gapX, fill_.gapY]; + obj.object.gapX = fill_.gapX; + obj.object.gapY = fill_.gapY; } if(obj.level2Type === "Pattern"){ prints.push(obj); @@ -1634,7 +1635,7 @@ export class CanvasManager { isPrintTrims: true, blendMode: blendMode, fabricObjects: [image.toObject(["id", "layerId", "layerName"])], - metadata: {sourceData: item}, + metadata: {sourceData: item, level2Type: item.level2Type}, }) children.push(layer); };