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, height: object.height,
} }
}; };
const fdObject = this.canvasManager.getFixedLayerObject();
const bgObject = this.canvasManager.getBackgroundLayerObject(); const bgObject = this.canvasManager.getBackgroundLayerObject();
const tObject = fdObject || bgObject;
const pattern = new fabric.Pattern({ const pattern = new fabric.Pattern({
source: img, source: img,
repeat: this.fillRepeat, repeat: this.fillRepeat,
patternTransform: object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(scale, 0), patternTransform: object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(scale, 0),
offsetX: object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : bgObject.width / 2, // 水平偏移 offsetX: object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : tObject.width / 2, // 水平偏移
offsetY: object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : bgObject.height / 2, // 垂直偏移 offsetY: object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : tObject.height / 2, // 垂直偏移
}); });
const rect = new fabric.Rect({ const rect = new fabric.Rect({
id: object.id, id: object.id,
@@ -143,13 +145,13 @@ export class FillRepeatCommand extends Command {
flipY: object.flipY, flipY: object.flipY,
}); });
} else { } else {
let scaleX = bgObject.scaleX || 1; let scaleX = tObject.scaleX || 1;
let scaleY = bgObject.scaleY || 1; let scaleY = tObject.scaleY || 1;
rect.set({ rect.set({
width: bgObject.width, width: tObject.width,
height: bgObject.height, height: tObject.height,
top: bgObject.top - bgObject.height * scaleY / 2, top: tObject.top - tObject.height * scaleY / 2,
left: bgObject.left - bgObject.width * scaleX / 2, left: tObject.left - tObject.width * scaleX / 2,
scaleX, scaleX,
scaleY, scaleY,
}); });
@@ -305,6 +307,7 @@ export class FillRepeatGapChangeCommand extends Command {
object.fill_.gapY = this.newGapY; object.fill_.gapY = this.newGapY;
} }
const image = new Image(); const image = new Image();
image.crossOrigin = "anonymous";
image.src = object.fill_.source; image.src = object.fill_.source;
await image.decode(); await image.decode();
object.fill_.width = image.width; object.fill_.width = image.width;

View File

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

View File

@@ -1187,7 +1187,8 @@ export class CanvasManager {
obj.scale = [scaleXY, scaleXY]; obj.scale = [scaleXY, scaleXY];
obj.angle = angle; obj.angle = angle;
obj.location = [left, top]; obj.location = [left, top];
obj.gap = [fill_.gapX, fill_.gapY]; obj.object.gapX = fill_.gapX;
obj.object.gapY = fill_.gapY;
} }
if(obj.level2Type === "Pattern"){ if(obj.level2Type === "Pattern"){
prints.push(obj); prints.push(obj);
@@ -1634,7 +1635,7 @@ export class CanvasManager {
isPrintTrims: true, isPrintTrims: true,
blendMode: blendMode, blendMode: blendMode,
fabricObjects: [image.toObject(["id", "layerId", "layerName"])], fabricObjects: [image.toObject(["id", "layerId", "layerName"])],
metadata: {sourceData: item}, metadata: {sourceData: item, level2Type: item.level2Type},
}) })
children.push(layer); children.push(layer);
}; };