From fb90ae5f26fb44eb608b3a0570f7035e883c3dee Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Sun, 19 Jan 2025 12:50:22 +0000 Subject: [PATCH] feat: hold alt with lasso tool to remove blocks from selection --- src/components/canvas/Canvas.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/canvas/Canvas.tsx b/src/components/canvas/Canvas.tsx index 50a793b..3431356 100644 --- a/src/components/canvas/Canvas.tsx +++ b/src/components/canvas/Canvas.tsx @@ -156,11 +156,15 @@ function Canvas() { const tileY = radiusPosition.y + y; 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; } @@ -324,7 +328,7 @@ function Canvas() { break; case "Alt": setHoldingAlt(true); - setCssCursor("zoom-out"); + if (tool === "zoom") setCssCursor("zoom-out"); break; case "Delete": { setBlocks((prev) => prev.filter((b) => !selectionCoordsRef.current.some(([x2, y2]) => x2 === b.x && y2 === b.y))); @@ -412,12 +416,7 @@ function Canvas() { }, []); return ( -
null} - style={{ cursor: cssCursor }} - className="relative w-full h-full bg-zinc-200 dark:bg-black" - > +