ExTermbox v1.0.2 ExTermbox.Position View Source

Represents a position on the screen by encoding a pair of cartesian coordinates. The origin is the top-left-most character on the screen (0, 0), while x and y increase from left to right and top to bottom, respectively.

Link to this section Summary

Functions

Translates (shifts) a position by some delta x and y.

Translates a position by a delta x.

Translates a position by a delta y.

Link to this section Types

Link to this type

t()

View Source
t() :: %ExTermbox.Position{x: non_neg_integer(), y: non_neg_integer()}

Link to this section Functions

Link to this function

translate(position, dx, dy)

View Source
translate(t(), integer(), integer()) :: t()

Translates (shifts) a position by some delta x and y.

Returns a new %Position{}.

Examples

iex> translate(%Position{x: 0, y: 0}, 1, 2)
%Position{x: 1, y: 2}
iex> translate(%Position{x: 10, y: 0}, -1, 0)
%Position{x: 9, y: 0}
Link to this function

translate_x(pos, dx)

View Source
translate_x(t(), integer()) :: t()

Translates a position by a delta x.

Returns a new %Position{}.

Examples

iex> translate_x(%Position{x: 0, y: 0}, 2)
%Position{x: 2, y: 0}
iex> translate_x(%Position{x: 2, y: 0}, -1)
%Position{x: 1, y: 0}
Link to this function

translate_y(pos, dy)

View Source
translate_y(t(), integer()) :: t()

Translates a position by a delta y.

Returns a new %Position{}.

Examples

iex> translate_y(%Position{x: 0, y: 0}, 2)
%Position{x: 0, y: 2}
iex> translate_y(%Position{x: 0, y: 2}, -1)
%Position{x: 0, y: 1}