This commit is contained in:
李志鹏
2026-01-19 13:37:24 +08:00
parent e81049c332
commit 87fd5b9a93
3 changed files with 15 additions and 10 deletions

View File

@@ -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;

View File

@@ -125,6 +125,7 @@
"
:options="selectOptions"
@change="(e) => changeFillRepeat(e, v)"
:disabled="v.layer?.metadata?.level2Type === 'Embroidery'"
/>
</div>
<!-- 平铺设置 -->

View File

@@ -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);
};