深度画布-平铺设置

This commit is contained in:
lzp
2026-03-16 16:51:12 +08:00
parent 1667d8d3a9
commit dc5d932b11
15 changed files with 539 additions and 59 deletions

View File

@@ -46,6 +46,7 @@ export class CanvasManager {
this.deviceInfo = detectDeviceType();
this.currentZoom = ref(100)
}
onMounted() { }
setCanvasViewSize(options) {
this.canvasViewWidth = options.canvasViewWidth || 1920
this.canvasViewHeight = options.canvasViewHeight || 1080
@@ -106,15 +107,15 @@ export class CanvasManager {
// this.stateManager.toolManager.setTool(OperationType.RECTANGLE)
}
/** 画布添加对象 */
async add(obj: any, isUpdate = true) {
async add(obj: any, isRecord = true) {
this.canvas.add(obj)
const id = obj?.info?.id || ""
if (isUpdate) {
if (id) {
this.layerManager.updateLayers()
this.renderAll()
if (id) await this.layerManager.updateLayerThumbnailsById(id)
this.stateManager.recordState()
await this.layerManager.updateLayerThumbnailsById(id)
}
if (isRecord) this.stateManager.recordState()
}
/** 画布移除对象 */
remove(obj: any, isUpdate = true) {
@@ -149,26 +150,22 @@ export class CanvasManager {
}
// 使用动画管理器的缩放方法
animateZoom(point, targetZoom, options = {}) {
console.log(point, targetZoom, options)
this.animationManager.animateZoom(point, targetZoom, options);
}
zoomIn() {
const currentZoom = this.canvas.getZoom()
const newZoom = Math.min(currentZoom + 0.1, 20) // 增加20%最大20倍
// 使用画布中心作为缩放点
const centerPoint = {
x: this.canvas.width / 2,
y: this.canvas.height / 2
}
this.animateZoom(centerPoint, newZoom)
}
zoomOut() {
const currentZoom = this.canvas.getZoom()
const newZoom = Math.max(currentZoom - 0.1, 0.1) // 减少20%最小0.1倍
// 使用画布中心作为缩放点
const centerPoint = {
x: this.canvas.width / 2,