hexgrid v2.1.1 HexGrid.Map

Map for Hexes. Allows for adding/removing tiles and setting data on them.

Link to this section Summary

Types

Result returned from Map functions

t()

Map

Functions

Gets the value from the map

Adds the tile to the map

Creates an empty map

Creates a Hexagonal-shaped map with a given radius

Sets the arbitrary value on a map

Link to this section Types

Link to this type result()
result() :: {:ok, term} | {:error, term}

Result returned from Map functions

Link to this type t()
t() :: %HexGrid.Map{data: Map.t}

Map

Link to this section Functions

Gets the value from the map.

Link to this function insert(map, hex)
insert(t, HexGrid.Hex.t) :: result

Adds the tile to the map

Creates an empty map

Examples:

iex> HexGrid.Map.new() {:ok, %HexGrid.Map{}}

Link to this function new_hex(radius)
new_hex(non_neg_integer) :: result

Creates a Hexagonal-shaped map with a given radius

Examples:

iex> HexGrid.Map.new_hex(0) {:ok, %HexGrid.Map{data: %{%HexGrid.Hex{q: 0, r: 0, s: 0} => %{}}}}

Link to this function set(map, hex, key, value)

Sets the arbitrary value on a map.