深度画布调整

This commit is contained in:
lzp
2026-03-16 11:38:58 +08:00
parent 9cd8d82e9e
commit dec750ab48
5 changed files with 45 additions and 4 deletions

View File

@@ -426,6 +426,8 @@ export class BrushIndicator {
this.canvas.on("mouse:over", this._mouseEnterHandler);
this.canvas.on("mouse:out", this._mouseLeaveHandler);
this.canvas.on("mouse:move", this._mouseMoveHandler);
this._observeCanvasChanges();
}
/**

View File

@@ -147,6 +147,35 @@ export class CanvasManager {
resetZoom() {
this.animationManager.resetZoom()
}
// 使用动画管理器的缩放方法
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,
y: this.canvas.height / 2
}
this.animateZoom(centerPoint, newZoom)
}
getObjects() {
return this.canvas.getObjects() || []
}

View File

@@ -487,7 +487,8 @@ export class BrushManager {
// 更新活动笔刷
if (this.activeBrush) {
this.activeBrush.configure(this.canvas.freeDrawingBrush, { color });
const currentOpacity = this.brushStore.state.opacity;
this.activeBrush.configure(this.canvas.freeDrawingBrush, { color, opacity: currentOpacity });
}
// 更新笔刷指示器大小