vivid v0.2.1 Vivid.Box

Short-hand for creating rectangle polygons.

This module doesn’t have very much logic other than knowing how to turn itself into a Polygon.

Summary

Functions

Return the bottom left corner of the box

Return the top right corner of the box

Initialize a Box from it’s bottom left and top right points

Initialize a box from the bounds of an arbitrary shape

Convert a Box into a Polygon

Return the top left corner of the box

Return the top right corner of the box

Types

t()
t

Functions

bottom_left(box)
bottom_left(Vivid.Box.t) :: Vivid.Point.t

Return the bottom left corner of the box.

Example

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
...> |> Box.bottom_left
#Vivid.Point<{1, 1}>
bottom_right(box)
bottom_right(Vivid.Box.t) :: Vivid.Point.t

Return the top right corner of the box.

Example

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
...> |> Box.bottom_right
#Vivid.Point<{4, 1}>
init(bl, tr)

Initialize a Box from it’s bottom left and top right points.

Examples

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
#Vivid.Box<[bottom_left: #Vivid.Point<{1, 1}>, top_right: #Vivid.Point<{4, 4}>]>
init_from_bounds(shape, fill \\ false)

Initialize a box from the bounds of an arbitrary shape.

Examples

iex> use Vivid
...> Circle.init(Point.init(5,5), 5)
...> |> Box.init_from_bounds
#Vivid.Box<[bottom_left: #Vivid.Point<{0.0, 0.2447174185242318}>, top_right: #Vivid.Point<{10.0, 9.755282581475768}>]>
to_polygon(box)
to_polygon(Vivid.Box.t) :: Vivid.Polygon.t

Convert a Box into a Polygon.

Example

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
...> |> Box.to_polygon
#Vivid.Polygon<[#Vivid.Point<{1, 1}>, #Vivid.Point<{1, 4}>, #Vivid.Point<{4, 4}>, #Vivid.Point<{4, 1}>]>
top_left(box)
top_left(Vivid.Box.t) :: Vivid.Point.t

Return the top left corner of the box.

Example

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
...> |> Box.top_left
#Vivid.Point<{1, 4}>
top_right(box)
top_right(Vivid.Box.t) :: Vivid.Point.t

Return the top right corner of the box.

Example

iex> use Vivid
...> Box.init(Point.init(1,1), Point.init(4,4))
...> |> Box.top_right
#Vivid.Point<{4, 4}>