Smart representation of a hexagon in a hexagonal grid, positioned on three axis. Very practical for a lots of algorithms. Sum of these coordinates is always 0, so technically only q and r are actually necessary (these are called axial coordinates, see Cube.fromAxial)).
See https://www.redblobgames.com/grids/hexagons/#coordinates for more information.
Rather impractical representation of a hexagon in a hexagonal grid, positioned by q (column) and r (row) coordinates.
"Zero" hexagon is in the top left corner. Odd rows (columns) are shifted to the right (down).
See https://www.redblobgames.com/grids/hexagons/#coordinates for more information.
This is a path from one hex to another. It contains the total cost of the path,
and the list of hexes that make up the path. See Hex.cheapestPathTo for more details.
This class represents a point on a screen or canvas. Easily convert it to Flutter Offset (Offset(pixel.x, pixel.y))
or whatever object your framework desires.
Two possible layouts of a hexagonal grid, which are used to convert between cube and offset coordinates, or when actually drawing the grid.
In https://www.redblobgames.com/grids/hexagons/ these are called "odd-r" (pointy) and "odd-q" (flat).
Returns moving window of segments of defined size. With path a,b,c,d,e and segmentSize 3, this method returns: [a,b,c, b,c,d, c,d,e]. If the segments size is
bigger then the path length, the method returns the whole path as a one segment.
This global function allows you to enforce repeatable random results within this library. You should set this seed only once and before first the 'random' method call.
This function describes the cost of moving from one hex to another. Both hexes are adjacent.
The cost is a double value, where double.infinity means that the move is impossible (target hex is a wall).
The cost should always be > 0, but this is not enforced.