Change fog brush to simplify on pointer up instead of pointer move

This commit is contained in:
Mitchell McCaffrey 2021-08-21 17:09:32 +10:00
parent 91f44f9eda
commit c710096f8b

View File

@ -223,15 +223,11 @@ function FogTool({
) {
return prevShape;
}
const simplified = simplifyPoints(
[...prevPoints, brushPosition],
1 / 1000 / stageScale
);
return {
...prevShape,
data: {
...prevShape.data,
points: simplified,
points: [...prevPoints, brushPosition],
},
};
});
@ -267,8 +263,15 @@ function FogTool({
(toolSettings.type === "brush" || toolSettings.type === "rectangle") &&
drawingShape
) {
let simplifiedShape = { ...drawingShape };
if (toolSettings.type === "brush") {
simplifiedShape.data.points = simplifyPoints(
simplifiedShape.data.points,
1 / 1000 / stageScale
);
}
const cut = toolSettings.useFogCut;
let drawingShapes = [drawingShape];
let drawingShapes = [simplifiedShape];
// Filter out hidden or visible shapes if single layer enabled
if (!toolSettings.multilayer) {
@ -277,7 +280,7 @@ function FogTool({
);
const subtractAction = new SubtractFogAction(shapesToSubtract);
const state = subtractAction.execute({
[drawingShape.id]: drawingShape,
[simplifiedShape.id]: simplifiedShape,
});
drawingShapes = Object.values(state)
.filter((shape) => shape.data.points.length > 2)