Is this hex grid column-based (flat-topped), or row-based (pointy-topped)?
Is this hex grid even or odd?
Grid Unit Width
Grid Unit Height
Special border polygons for different token sizes.
Special border polygons for different token sizes.
An array of the points which define a hexagon for this grid shape
A matrix of x and y offsets which is multiplied by the width/height vector to get pointy-top polygon coordinates
A matrix of x and y offsets which is multiplied by the width/height vector to get flat-top polygon coordinates
Draw the grid. Subclasses are expected to override this method to perform their type-specific drawing logic.
A convenience method for getting all the polygon points relative to a top-left [x,y] coordinate pair
The top-left x-coordinate
The top-right y-coordinate
Get a border polygon based on the width and height of a given token.
The width of the token in hexes.
The height of the token in hexes.
The padding size in pixels.
Calculate the resulting token position after moving along a ruler segment.
The ray being moved along.
The offset of the ruler's origin relative to the token's position.
The token placeable being moved.
Determine a placeable's bounding box based on the size of the grid.
The width in grid spaces.
The height in grid spaces.
Measure the distance in grid units between two pixel-based coordinates.
The initial point
The terminal point
The measured distance in grid units
Compute the shortest path between two hexagons using the A-star algorithm. See https://www.redblobgames.com/pathfinding/a-star/introduction.html for reference
The optimal path of hexagons to traverse
Convert an offset coordinate (row, col) into a cube coordinate (q, r, s). See https://www.redblobgames.com/grids/hexagons/ for reference Source code available https://www.redblobgames.com/grids/hexagons/codegen/output/lib-functions.js
The offset coordinate
The cube coordinate
Convert a cube coordinate (q, r, s) into an offset coordinate (row, col). See https://www.redblobgames.com/grids/hexagons/ for reference Source code available https://www.redblobgames.com/grids/hexagons/codegen/output/lib-functions.js
The cube coordinate
The offset coordinate
Given a pair of coordinates (x, y) - return the top-left of the grid square which contains that point
An Array [x, y] of the top-left coordinate of the square which contains (x, y)
Compute hexagonal grid width and height.
Size of the hex.
Compute and draw row style hexagons.
Reference to the grid graphics.
Number of rows.
Number of columns.
Compute and draw column style hexagons.
Reference to the grid graphics.
Number of rows.
Number of columns.
Draw a hexagon from polygon points.
Reference to the grid graphics.
Array of points to draw the hexagon.
Implement special rules for snapping tokens of various sizes on a hex grid.
The X co-ordinate of the hexagon's top-left bounding box.
The Y co-ordinate of the hexagon's top-left bounding box.
The token.
Implement special rules for determining the grid position of tokens of various sizes on a hex grid.
The row number.
The column number.
The token.
The adjusted row and column number.
Draw the grid lines.
Override settings used in place of those saved to the scene data.
Get the position in grid space from a pixel coordinate.
The origin x-coordinate
The origin y-coordinate
The rounding method applied
The row, column combination
Calculate the total size of the canvas with padding applied, as well as the top-left co-ordinates of the inner rectangle that houses the scene.
The grid type to calculate padding for. {@see CONST.GRID_TYPES}
The width of the scene.
The height of the scene.
The grid size.
The percentage of padding.
Given a cursor position (x, y), obtain the cube coordinate hex (q, r, s) of the hex which contains it http://justinpombrio.net/programming/2020/04/28/pixel-to-hex.html
The pixel point
The cube coordinate
Measure the distance in hexagons between two cube coordinates.
The first cube coordinate
The second cube coordinate
The distance between the two cube coordinates in hexagons
Returns the class responsible for the implementation of a given grid type.
The grid type. {@see CONST.GRID_TYPES}
(typeof BaseGrid) A constructor for a grid of the given type.
Legacy hex sizing set the 'size' of a hexagon (the distance from a hexagon's centre to a vertex) to be equal to half the grid size. This created some measuring inaccuracies that added up over larger distances.
The grid size.
Are the hexagons stacked in columns, or rows?
The width and height of a single hexagon, in pixels.
We set the 'size' of a hexagon (the distance from a hexagon's centre to a vertex) to be equal to the grid size divided by √3. This makes the distance from top-to-bottom on a flat-topped hexagon, or left-to-right on a pointy- topped hexagon equal to the grid size.
The grid size.
Are the hexagons stacked in columns, or rows?
The width and height of a single hexagon, in pixels.
Construct a hexagonal grid