fix
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user