hexgrid v2.0.0 HexGrid.Map

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

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

Types

result()
result :: {:ok, term} | {:error, term}

Result returned from Map functions

t()
t :: %HexGrid.Map{data: Map.t}

Map

Functions

get(map, hex, key)
get(t, HexGrid.Hex.t, any) :: any

Gets the value from the map.

insert(map, hex)
insert(t, HexGrid.Hex.t) :: result

Adds the tile to the map

new()
new :: result

Creates an empty map

Examples:

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

new_hex(radius)
new_hex(integer) :: result

Creates a Hexagonal-shaped map with a given radius

Examples:

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

set(map, hex, key, value)
set(t, HexGrid.Hex.t, any, any) :: result

Sets the arbitrary value on a map.