From efe2d00339cca3788089ea208a4ec746151f58fb Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Fri, 31 Jan 2025 14:18:08 +0000 Subject: [PATCH] feat: inverse selection --- src/components/menubar/SelectMenu.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/menubar/SelectMenu.tsx b/src/components/menubar/SelectMenu.tsx index 3426917..6968d30 100644 --- a/src/components/menubar/SelectMenu.tsx +++ b/src/components/menubar/SelectMenu.tsx @@ -24,6 +24,19 @@ function SelectMenu() { setSelectionCoords(newSelection); }; + // Add every block that isn't within in the selectio and within the canvas size to the temporary array + const inverse = () => { + const newSelection: CoordinateArray = []; + + for (let x = canvasSize.minX; x < canvasSize.maxX; x++) { + for (let y = canvasSize.minY; y < canvasSize.maxY; y++) { + if (!selection.isIn(selectionCoords, x, y)) newSelection.push([x, y]); + } + } + + setSelectionCoords(newSelection); + }; + return ( Select @@ -33,6 +46,7 @@ function SelectMenu() { Ctrl A setSelectionCoords([])}>Clear + Inverse );