feat: hold alt with lasso tool to remove blocks from selection

This commit is contained in:
trafficlunar 2025-01-19 12:50:22 +00:00
parent fdabe89dd5
commit fb90ae5f26

View file

@ -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]);
} }
} }
return [...prev, ...radiusCoords]; if (holdingAlt) {
return prev.filter(([x, y]) => !radiusCoords.some(([x2, y2]) => x2 === x && y2 === y));
} else {
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}