feat: 添加笔刷指示器功能,支持动态显示当前笔刷大小和颜色;更新图层可擦除状态逻辑

This commit is contained in:
bighuixiang
2025-06-24 01:54:37 +08:00
parent 2446f91376
commit e001c9dd49
5 changed files with 725 additions and 3 deletions

View File

@@ -328,6 +328,26 @@ export class CanvasManager {
this.canvas.renderAll();
}
// 设置固定图层可擦除状态
setFixedLayerErasable({ type = "isFixed", flag = false }) {
const layer = this.layers.value.find((layer) => layer[type]);
if (layer) {
// 设置固定图层的可擦除状态
layer.locked = flag;
// 更新画布对象的erasable属性
const fabricObject = this.canvas
.getObjects()
.find((obj) => obj.id === layer.id);
if (fabricObject) {
fabricObject.erasable = flag;
fabricObject.set("erasable", flag);
fabricObject.setCoords(); // 更新控制点坐标
this.canvas.renderAll(); // 重新渲染画布
}
return;
}
}
setCanvasSize(width, height) {
this.width = width;
this.height = height;