Documentation ¶
Overview ¶
Package hexgrid provides various utilities to handle regular hexagons math This is a GO implementation of the algorithms described at http://www.redblobgames.com/grids/hexagons/implementation.html
Index ¶
- func HexAdd(a, b hex) hex
- func HexCornerOffset(l layout, c int) point
- func HexDistance(a, b hex) int
- func HexFieldOfView(source hex, candidates []hex, blocking []hex) []hex
- func HexHasLineOfSight(center hex, target hex, blocking []hex) bool
- func HexLength(hex hex) int
- func HexLineDraw(a, b hex) []hex
- func HexNeighbor(h hex, direction direction) hex
- func HexRange(center hex, radius int) []hex
- func HexRectangleGrid(width, height int) []hex
- func HexScale(a hex, k int) hex
- func HexSubtract(a, b hex) hex
- func HexToPixel(l layout, h hex) point
- func HexagonCorners(l layout, h hex) []point
- func NewFractionalHex(q, r float64) fractionalHex
- func NewHex(q, r int) hex
- func PixelToHex(l layout, p point) fractionalHex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HexCornerOffset ¶
func HexCornerOffset(l layout, c int) point
func HexDistance ¶
func HexDistance(a, b hex) int
func HexFieldOfView ¶
func HexFieldOfView(source hex, candidates []hex, blocking []hex) []hex
Returns the list of hexagons that are visible from a given hexagon
func HexHasLineOfSight ¶
func HexHasLineOfSight(center hex, target hex, blocking []hex) bool
Determines if a given hexagon is visible from another hexagon, taking into consideration a set of blocking hexagons
func HexLineDraw ¶
func HexLineDraw(a, b hex) []hex
Returns the slice of hexagons that exist on a line that goes from hexagon a to hexagon b
func HexNeighbor ¶
func HexNeighbor(h hex, direction direction) hex
Returns the neighbor hexagon at a certain direction
func HexRange ¶
func HexRange(center hex, radius int) []hex
Returns the set of hexagons around a certain center for a given radius
func HexRectangleGrid ¶
func HexRectangleGrid(width, height int) []hex
Returns the set of hexagons that form a rectangle with the specified width and height
func HexScale ¶
func HexScale(a hex, k int) hex
Scales an hexagon by a k factor. If factor k is 1 there's no change
func HexToPixel ¶
func HexToPixel(l layout, h hex) point
HexToPixel returns the center pixel for a given hexagon an a certain layout
func HexagonCorners ¶
func HexagonCorners(l layout, h hex) []point
Gets the corners of the hexagon for the given layout, starting at the E vertex and proceeding in a CCW order
func NewFractionalHex ¶
func NewFractionalHex(q, r float64) fractionalHex
func PixelToHex ¶
func PixelToHex(l layout, p point) fractionalHex
PixelToHex returns the corresponding hexagon axial coordinates for a given pixel on a certain layout
Types ¶
This section is empty.