feat: 优化填充组图层背景命令,重构填充对象创建逻辑
This commit is contained in:
@@ -123,6 +123,21 @@ export class FillGroupLayerBackgroundCommand extends Command {
|
||||
scaleX: clippingMaskFabricObject.scaleX || 1,
|
||||
scaleY: clippingMaskFabricObject.scaleY || 1,
|
||||
});
|
||||
} else {
|
||||
this.newFill = new fabric.Rect({
|
||||
width: this.canvasManager?.canvasWidth?.value || this.canvas.width,
|
||||
height: this.canvasManager?.canvasHeight?.value || this.canvas.height,
|
||||
left: this.canvas.width / 2 || 0,
|
||||
top: this.canvas.height / 2 || 0,
|
||||
fill: this.fillColor,
|
||||
layerId: this.layerId,
|
||||
id: this.oldFill?.id || generateId("fill-"),
|
||||
selectable: false,
|
||||
evented: false,
|
||||
originX: "center",
|
||||
originY: "center",
|
||||
});
|
||||
}
|
||||
this.newFill.clipPath = clippingMaskFabricObject; // 设置填充的遮罩
|
||||
this.newFill.dirty = true; // 标记为脏,以便重新
|
||||
this.canvas.add(this.newFill);
|
||||
@@ -144,8 +159,6 @@ export class FillGroupLayerBackgroundCommand extends Command {
|
||||
this.canvasManager.thumbnailManager?.generateLayerThumbnail(
|
||||
this.layer.id
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
const canvasObj = findObjectById(this.canvas, firstObj?.id)?.object;
|
||||
|
||||
Reference in New Issue
Block a user