vivid v0.2.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 true if the point is within the bounds

Returns the height of a shape

Initialise arbitrary bounds

Returns the top-right point of the bounds

Returns the bottom-left point of the bounds

Returns the width of a shape

Types

t()
t

Functions

bounds(bounds)

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, 0.0}>, max: #Vivid.Point<{20.0, 20.0}>]>
center_of(shape)

Returns the center point of the bounds.

Example

iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Circle.to_polygon
...> |> Vivid.Bounds.center_of
#Vivid.Point<{10.0, 10.0}>
contains?(arg1, arg2)
contains?(Vivid.Shape.t, Vivid.Point.t) :: boolean

Returns true if the point is within the bounds.

Examples

iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(0, 0))
  true

  iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(5, 5))
  true

  iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(-1, -1))
  false

  iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(-10, -10))
  false

  iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(10, 10))
  true

  iex> Vivid.Bounds.init(0, 0, 10, 10)
  ...> |> Vivid.Bounds.contains?(Vivid.Point.init(11, 11))
  false
height(shape)
height(Vivid.Shape.t) :: number

Returns the height of a shape.

Example

iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.height
20.0
init(x0, y0, x1, y1)
init(number, number, number, number) :: Vivid.Bounds.t

Initialise arbitrary bounds.

Example

iex> Vivid.Bounds.init(0, 0, 5, 5)
#Vivid.Bounds<[min: #Vivid.Point<{0, 0}>, max: #Vivid.Point<{5, 5}>]>
max(shape)

Returns the top-right point of the bounds.

Example

iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.max
#Vivid.Point<{20.0, 20.0}>
min(shape)

Returns the bottom-left point of the bounds.

Example

iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.min
#Vivid.Point<{0.0, 0.0}>
width(shape)
width(Vivid.Shape.t) :: number

Returns the width of a shape.

Example

iex> Vivid.Circle.init(Vivid.Point.init(10,10), 10)
...> |> Vivid.Bounds.width
20.0