老数据重置画布大小
This commit is contained in:
@@ -139,7 +139,7 @@ const props = defineProps({
|
|||||||
default: false, // 是否隐藏画布-隐藏关闭部分功能
|
default: false, // 是否隐藏画布-隐藏关闭部分功能
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log("config",props.config)
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
// 引用和状态
|
// 引用和状态
|
||||||
const canvasRef = ref(null);
|
const canvasRef = ref(null);
|
||||||
|
|||||||
@@ -449,7 +449,28 @@ export class CanvasManager {
|
|||||||
// // 重新渲染画布使变更生效
|
// // 重新渲染画布使变更生效
|
||||||
// this.canvas.renderAll();
|
// this.canvas.renderAll();
|
||||||
}
|
}
|
||||||
|
// 重置画布大小参照固定图层
|
||||||
|
async resetCanvasSizeByFixedLayer(){
|
||||||
|
// 重置画布大小为固定图层的大小
|
||||||
|
const fixedLayerObj = this.getFixedLayerObject();
|
||||||
|
const backgroundObject = this.getBackgroundLayerObject();
|
||||||
|
if (!fixedLayerObj || !backgroundObject) return
|
||||||
|
const fwidth = fixedLayerObj.width * fixedLayerObj.scaleX
|
||||||
|
const fheight = fixedLayerObj.height * fixedLayerObj.scaleY
|
||||||
|
const bwidth = backgroundObject.width * backgroundObject.scaleX
|
||||||
|
const bheight = backgroundObject.height * backgroundObject.scaleY
|
||||||
|
if(Math.abs(fwidth/bwidth - fheight/bheight) < 0.1) return;
|
||||||
|
this.canvasWidth.value = fwidth
|
||||||
|
this.canvasHeight.value = fheight
|
||||||
|
backgroundObject.set({
|
||||||
|
width: this.canvasWidth.value,
|
||||||
|
height: this.canvasHeight.value,
|
||||||
|
})
|
||||||
|
this.canvas?.clipPath?.set?.({
|
||||||
|
width: this.canvasWidth.value,
|
||||||
|
height: this.canvasHeight.value,
|
||||||
|
})
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 重置视图变换,使元素回到原始位置
|
* 重置视图变换,使元素回到原始位置
|
||||||
* @private
|
* @private
|
||||||
@@ -1369,6 +1390,7 @@ export class CanvasManager {
|
|||||||
// 重置画布数据
|
// 重置画布数据
|
||||||
await this.setCanvasSize(this.canvas.width, this.canvas.height);
|
await this.setCanvasSize(this.canvas.width, this.canvas.height);
|
||||||
await this.centerBackgroundLayer(this.canvas.width, this.canvas.height);
|
await this.centerBackgroundLayer(this.canvas.width, this.canvas.height);
|
||||||
|
await this.resetCanvasSizeByFixedLayer();
|
||||||
// 重新构建对象关系
|
// 重新构建对象关系
|
||||||
// restoreObjectLayerAssociations(this.layers.value, this.canvas.getObjects());
|
// restoreObjectLayerAssociations(this.layers.value, this.canvas.getObjects());
|
||||||
// 验证图层关联关系 - 稳定后可以注释
|
// 验证图层关联关系 - 稳定后可以注释
|
||||||
|
|||||||
Reference in New Issue
Block a user