View Source Hold.Coordinate (hold v0.1.0)

A coordinate in an xy plane with (0,0) being the top left corner.

Summary

Functions

Return all surrounding coordinates.

Return downward coordinate.

Return coordinate to the left

Create a new Coordinate

Return coordinate to the right

Return upward coordinate.

Types

@type t() :: {x :: integer(), y :: integer()}

Functions

@spec around(t()) :: [t(), ...]

Return all surrounding coordinates.

iex> Hold.Coordinate.around({1, 1})
[{1, 0}, {1, 2}, {2, 1}, {2, 0}, {2, 2}, {0, 1}, {0, 0}, {0, 2}]
@spec down(t()) :: t()

Return downward coordinate.

iex> Hold.Coordinate.down({0, 1})
{1, 1}

iex> Hold.Coordinate.down({-1, 0})
{0, 0}
@spec left(t()) :: t()

Return coordinate to the left

iex> Hold.Coordinate.left({1, 1})
{1, 0}

iex> Hold.Coordinate.left({0, -1})
{0, -2}
@spec new(x :: integer(), y :: integer()) :: t()

Create a new Coordinate

@spec right(t()) :: t()

Return coordinate to the right

iex> Hold.Coordinate.right({1, 1})
{1, 2}

iex> Hold.Coordinate.right({0, -1})
{0, 0}
@spec up(t()) :: t()

Return upward coordinate.

iex> Hold.Coordinate.up({0, 1})
{-1, 1}