平铺默认参数

This commit is contained in:
李志鹏
2026-02-02 11:33:36 +08:00
parent b320294764
commit 5d7cec520b

View File

@@ -109,12 +109,19 @@ export class FillRepeatCommand extends Command {
const fdObject = this.canvasManager.getFixedLayerObject();
const bgObject = this.canvasManager.getBackgroundLayerObject();
const tObject = fdObject || bgObject;
const tWidth = tObject.width;
const tHeight = tObject.height;
// const offsetX = object.fill?.hasOwnProperty("offsetX") ? object.fill.offsetX : tObject.width / 2;
// const offsetY = object.fill?.hasOwnProperty("offsetY") ? object.fill.offsetY : tObject.height / 2;
const patternTransform = object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(0.3, 0);
const scaleX_ = tWidth / img.width / 5;
const scaleY_ = tHeight / img.height / 5;
const scale_ = tWidth > tHeight ? scaleX_ : scaleY_;
const patternTransform = object.fill?.hasOwnProperty("patternTransform") ? object.fill.patternTransform : createPatternTransform(scale_, 0);
const scale = getTransformScaleAngle(patternTransform).scale;
const offsetX = tObject.width / 2 - img.width * scale / 2;
const offsetY = tObject.height / 2 - img.height * scale / 2;
const offsetX = tWidth / 2 - img.width * scale / 2;
const offsetY = tHeight / 2 - img.height * scale / 2;
const pattern = new fabric.Pattern({
source: img,
repeat: this.fillRepeat,
@@ -146,10 +153,10 @@ export class FillRepeatCommand extends Command {
let scaleX = tObject.scaleX || 1;
let scaleY = tObject.scaleY || 1;
rect.set({
width: tObject.width,
height: tObject.height,
top: tObject.top - tObject.height * scaleY / 2,
left: tObject.left - tObject.width * scaleX / 2,
width: tWidth,
height: tHeight,
top: tObject.top - tHeight * scaleY / 2,
left: tObject.left - tWidth * scaleX / 2,
scaleX,
scaleY,
});
@@ -192,7 +199,7 @@ export class FillRepeatCommand extends Command {
// 复制原对象的属性
copyObjectProperties(object) {
return{
return {
id: object.id,
layerId: object.layerId,
layerName: object.layerName,