feat: inverse selection
This commit is contained in:
parent
23efc8289c
commit
efe2d00339
1 changed files with 14 additions and 0 deletions
|
|
@ -24,6 +24,19 @@ function SelectMenu() {
|
||||||
setSelectionCoords(newSelection);
|
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 (
|
return (
|
||||||
<MenubarMenu>
|
<MenubarMenu>
|
||||||
<MenubarTrigger>Select</MenubarTrigger>
|
<MenubarTrigger>Select</MenubarTrigger>
|
||||||
|
|
@ -33,6 +46,7 @@ function SelectMenu() {
|
||||||
<MenubarShortcut>Ctrl A</MenubarShortcut>
|
<MenubarShortcut>Ctrl A</MenubarShortcut>
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarItem onClick={() => setSelectionCoords([])}>Clear</MenubarItem>
|
<MenubarItem onClick={() => setSelectionCoords([])}>Clear</MenubarItem>
|
||||||
|
<MenubarItem onClick={inverse}>Inverse</MenubarItem>
|
||||||
</MenubarContent>
|
</MenubarContent>
|
||||||
</MenubarMenu>
|
</MenubarMenu>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue