-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Spell): use hexes when using hex grids
- Loading branch information
Showing
5 changed files
with
145 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { type GlobalPoint } from "../../../core/geometry"; | ||
import type { GridType } from "../../../core/grid"; | ||
import type { GlobalId, LocalId } from "../../id"; | ||
import { createHex } from "../../rendering/grid"; | ||
|
||
import { Polygon } from "./polygon"; | ||
|
||
export function createHexPolygon( | ||
center: GlobalPoint, | ||
size: number, | ||
grid: { type: GridType; oddHexOrientation: boolean; radius?: number }, | ||
options?: { | ||
lineWidth?: number[]; | ||
openPolygon?: boolean; | ||
id?: LocalId; | ||
uuid?: GlobalId; | ||
isSnappable?: boolean; | ||
}, | ||
): Polygon { | ||
const vertices = createHex(center, size, grid); | ||
if (vertices.length < 2) { | ||
throw new Error("Hexagon has less than 2 vertices"); | ||
} | ||
return new Polygon(vertices[0]!, vertices.slice(1), options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters