深度画布bug

This commit is contained in:
lzp
2026-03-31 13:29:46 +08:00
parent f5efaa8eaf
commit b53d15d3f2
22 changed files with 381 additions and 91 deletions

View File

@@ -3,13 +3,13 @@ import { reactive, readonly } from "vue";
class texturePresetManager { }
export class BrushState {
constructor(options) {
constructor(options = {}) {
this.state = reactive({
// 笔刷基础属性
size: 5, // 笔刷大小
color: "#000000", // 笔刷颜色
opacity: 1, // 笔刷透明度
type: "pencil", // 当前笔刷类型
size: options.size || 5, // 笔刷大小
color: options.color || "#000000", // 笔刷颜色
opacity: options.opacity || 1, // 笔刷透明度
type: options.type || "pencil", // 当前笔刷类型
// 阴影相关属性
shadowEnabled: false, // 是否启用阴影

View File

@@ -21,6 +21,8 @@ import { EraserStateManager } from "../EraserStateManager.js";
import { SprayBrush } from "./types/SprayBrush";
// import { SketchyBrush } from "./types/SketchyBrush";
// import { SpraypaintBrush } from "./types/SpraypaintBrush";
import { OperationType } from '../../tools/layerHelper'
/**
* 笔刷管理器
@@ -37,7 +39,17 @@ export class BrushManager {
*/
constructor(options = {}) {
this.canvas = options.canvas;
this.brushStore = new BrushState();
this.brushStoreList = {
[OperationType.DRAW]: new BrushState(),
[OperationType.ERASER]: new BrushState(),
[OperationType.AISELECT_DRAW]: new BrushState({
color: "rgb(255, 0, 0)",
opacity: 0.5,
}),
[OperationType.AISELECT_ERASER]: new BrushState(),
}
this.brushStore = this.brushStoreList[OperationType.DRAW];
this.layerManager = options.layerManager; // 添加图层管理器引用
this.brushIndicator = options.brushIndicator; // 添加笔刷指示器引用
// this.t = options.t
@@ -55,7 +67,15 @@ export class BrushManager {
this.isErasingActive = false;
this.currentErasedObjects = []; // 当前擦除会话中被影响的对象
}
/**
* 切换工具时,更新当前活动笔刷
* @param {string} toolName 当前工具名称
*/
handleToolChange(toolName) {
const store = this.brushStoreList[toolName];
if (!store) return;
this.brushStore = store;
}
/**
* 注册默认笔刷
* @private