Crate hex_spiral

Source
Expand description

While most hex-grid-based 2D games use multiple coordinates, hex-spiral uses a single-coordinate spiral, where the central hex has the position 0, and further hexes are placed within theoretical hexagonal rings that surround it. The hexes are flat-topped and every ring is indexed starting with the hex on the top edge of the previous ring and with further positions growing clockwise.

Structs§

DirectionalNeighborIter
An iterator returning subsequent neighboring positions in the given direction. The top direction is 0, and it increases up to 5 clockwise.

Functions§

are_grouped
are_neighbors
Returns true if the given 2 positions are neighbors.
is_at_ring_tip
Returns true if the given position is at one of the tips of a ring.
is_path_consistent
Returns true if the given list of positions consists of subsequent neighbors.
neighboring_positions
Returns the 6 neighbors of the given position, always in the same clockwise order.
ring
The index of the ring for the given position.
ring_edge_index
Returns the index of the edge of the ring the given position belongs to.
ring_offset
The starting position of hexes within the ring with the given index.

Type Aliases§

Pos
RingIdx