feat: hold alt with lasso tool to remove blocks from selection
This commit is contained in:
parent
fdabe89dd5
commit
fb90ae5f26
1 changed files with 8 additions and 9 deletions
|
|
@ -156,11 +156,15 @@ function Canvas() {
|
||||||
const tileY = radiusPosition.y + y;
|
const tileY = radiusPosition.y + y;
|
||||||
|
|
||||||
const exists = prev.some(([x2, y2]) => x2 === tileX && y2 === tileY);
|
const exists = prev.some(([x2, y2]) => x2 === tileX && y2 === tileY);
|
||||||
if (!exists) radiusCoords.push([tileX, tileY]);
|
if ((holdingAlt && exists) || !exists) radiusCoords.push([tileX, tileY]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (holdingAlt) {
|
||||||
|
return prev.filter(([x, y]) => !radiusCoords.some(([x2, y2]) => x2 === x && y2 === y));
|
||||||
|
} else {
|
||||||
return [...prev, ...radiusCoords];
|
return [...prev, ...radiusCoords];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -324,7 +328,7 @@ function Canvas() {
|
||||||
break;
|
break;
|
||||||
case "Alt":
|
case "Alt":
|
||||||
setHoldingAlt(true);
|
setHoldingAlt(true);
|
||||||
setCssCursor("zoom-out");
|
if (tool === "zoom") setCssCursor("zoom-out");
|
||||||
break;
|
break;
|
||||||
case "Delete": {
|
case "Delete": {
|
||||||
setBlocks((prev) => prev.filter((b) => !selectionCoordsRef.current.some(([x2, y2]) => x2 === b.x && y2 === b.y)));
|
setBlocks((prev) => prev.filter((b) => !selectionCoordsRef.current.some(([x2, y2]) => x2 === b.x && y2 === b.y)));
|
||||||
|
|
@ -412,12 +416,7 @@ function Canvas() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div ref={stageContainerRef} style={{ cursor: cssCursor }} className="relative w-full h-full bg-zinc-200 dark:bg-black">
|
||||||
ref={stageContainerRef}
|
|
||||||
onContextMenu={() => null}
|
|
||||||
style={{ cursor: cssCursor }}
|
|
||||||
className="relative w-full h-full bg-zinc-200 dark:bg-black"
|
|
||||||
>
|
|
||||||
<Stage
|
<Stage
|
||||||
width={stageSize.width}
|
width={stageSize.width}
|
||||||
height={stageSize.height}
|
height={stageSize.height}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue