vivid v0.2.1 Vivid.Point

Represents an individual point in (2D) space.

Summary

Functions

Creates a Point

Round the coordinates in the point to the nearest integer value

Simple helper to swap X and Y coordinates - used when translating the frame buffer to vertical

Return the vector in x and y between point a and point b

Returns the X coordinate of the point

Returns the Y coordinate of the point

Types

t()
t

Functions

init(x, y)
init(number, number) :: Vivid.Point.t

Creates a Point.

Examples

iex> Vivid.Point.init(13, 27)
%Vivid.Point{x: 13, y: 27}
round(point)

Round the coordinates in the point to the nearest integer value.

Example

iex> Vivid.Point.init(1.23, 4.56)
...> |> Vivid.Point.round
#Vivid.Point<{1, 5}>
swap_xy(point)

Simple helper to swap X and Y coordinates - used when translating the frame buffer to vertical.

Example

iex> Vivid.Point.init(13, 27)
...> |> Vivid.Point.swap_xy
#Vivid.Point<{27, 13}>
vector(point1, point2)
vector(Vivid.Point.t, Vivid.Point.t) :: {number, number}

Return the vector in x and y between point a and point b.

Example

iex> use Vivid
...> a = Point.init(10, 10)
...> b = Point.init(20, 20)
...> Point.vector(a, b)
{10, 10}
x(point)
x(Vivid.Point.t) :: number

Returns the X coordinate of the point.

Examples

iex> Vivid.Point.init(13, 27) |> Vivid.Point.x
13
y(point)
y(Vivid.Point.t) :: number

Returns the Y coordinate of the point.

Examples

iex> Vivid.Point.init(13, 27) |> Vivid.Point.y
27