vivid v0.1.1 Vivid.Bounds
Provides information about the bounds of a box and pixel positions within it.
Summary
Functions
Return the bounding box required to encapsulate the shape
Returns the center point of the bounds
Returns the height of a shape
Initialise arbitrary bounds
Returns the bottom-left point of the bounds
Returns the bottom-left point of the bounds
Returns the width of a shape
Functions
Return the bounding box required to encapsulate the shape.
Example
iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.bounds
#Vivid.Bounds<[min: #Vivid.Point<{0, 0}>, max: #Vivid.Point<{20, 20}>]>
Returns the center point of the bounds.
Warning this function returns a Point with floating point coordinates,
which is great if you need to use it for maths, but will explode the render.
Make sure you pipe it through Point.round
before you use it.
Example
iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.center_of
#Vivid.Point<{10.0, 10.0}>
Returns the height of a shape.
Example
iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.height
20
Initialise arbitrary bounds.
Example
iex> Vivid.Bounds.init(0, 0, 5, 5)
#Vivid.Bounds<[min: #Vivid.Point<{0, 0}>, max: #Vivid.Point<{5, 5}>]>
Returns the bottom-left point of the bounds.
Example
iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.max
#Vivid.Point<{20, 20}>