部件选取框选工具合并操作

This commit is contained in:
李志鹏
2026-02-05 10:26:40 +08:00
parent a905971dae
commit 72c4898101
3 changed files with 26 additions and 20 deletions

View File

@@ -90,16 +90,17 @@ export class PartManager {
if (toolId === OperationType.PART_ERASER) {
this.setEraserTool();
} else if (toolId === OperationType.PART || toolId === OperationType.PART_RECTANGLE) {
this.clearPointData();
this.resetPartObject();
}
if (toolId === OperationType.PART_ERASER || toolId === OperationType.PART_BRUSH) {
if (this.pointList.length > 0) {
this.clearPointData();
this.resetPartObject();
}
}
}
// else if (toolId === OperationType.PART || toolId === OperationType.PART_RECTANGLE) {
// this.clearPointData();
// this.resetPartObject();
// }
// if (toolId === OperationType.PART_ERASER || toolId === OperationType.PART_BRUSH) {
// if (this.pointList.length > 0) {
// this.clearPointData();
// this.resetPartObject();
// }
// }
// 如果从非选区工具切换到选区工具,初始化事件
if (!wasActive && this.isActive) {
@@ -380,7 +381,8 @@ export class PartManager {
box: [...this.pointList],
});
const image = await this.loadImageToObject(url);
const canvas = getObjectAlphaToCanvas(image, null, 0, this.rgba);
const data = this.partCanvas?.getContext("2d")?.getImageData(0, 0, this.partCanvas.width, this.partCanvas.height);
const canvas = getObjectAlphaToCanvas(image, data, 0, this.rgba, !!data);
this.partDrawCommand(canvas);
}
/** 获取分隔后图片 */