vivid v0.4.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 an unfilled Box from it’s bottom left and top right points
Initialize a Box from it’s bottom left and top right points and whether it’s filled
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
Functions
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}>
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}>
Initialize an unfilled Box from it’s bottom left and top right points.
bottom_left
- the bottom leftPoint
of the box.top_right
- the top rightPoint
of the box.
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}>]>
Initialize a Box from it’s bottom left and top right points and whether it’s filled.
bottom_left
- the bottom leftPoint
of the box.top_right
- the top rightPoint
of the box.fill
- whether or not the box should be filled.
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}>]>
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}>]>
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}>]>
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}>