Module bound2

A 2 component bounding box.

Functions

new (min, max) The public constructor.
clone (a) Clone a bound.
at (a, b) Construct a bound covering one or two points
extend (a, point) Extend bound to include point
extend_bound (a, bound) Extend bound to entirety of other bound
size (a) Get size of bounding box as a vector
with_size (a, new) Resize bounding box from minimum corner
radius (a) Get half-size of bounding box as a vector.
center (a) Get center of bounding box
with_center (a, new) Move bounding box to new center
with_size_centered (a, new) Resize bounding box from center
check (a) Convert possibly-invalid bounding box to valid one
inset (a, a) Shrink bounding box with fixed margin
outset (a, a) Expand bounding box with fixed margin
offset (a, offset) Offset bounding box
contains (a, point) Test if point in bound
to_string (a) Return a formatted string.


Functions

new (min, max)
The public constructor.

Parameters:

  • min Can be of two types:
    vec2 min, minimum value for each component nil Create bound at single point 0,0
  • max vec2 , maximum value for each component

Returns:

    bound2 out
clone (a)
Clone a bound.

Parameters:

  • a bound2 bound to be cloned

Returns:

    bound2 out
at (a, b)
Construct a bound covering one or two points

Parameters:

  • a vec2 Any vector
  • b vec2 Any second vector (optional)

Returns:

    vec2 Minimum bound containing the given points
extend (a, point)
Extend bound to include point

Parameters:

  • a bound2 bound
  • point vec2 to include

Returns:

    bound2 Bound covering current min, current max and new point
extend_bound (a, bound)
Extend bound to entirety of other bound

Parameters:

  • a bound2 bound
  • bound bound2 to cover

Returns:

    bound2 Bound covering current min and max of each bound in the pair
size (a)
Get size of bounding box as a vector

Parameters:

  • a bound2 bound

Returns:

    vec2 Vector spanning min to max points
with_size (a, new)
Resize bounding box from minimum corner

Parameters:

  • a bound2 bound
  • new vec2 size

Returns:

    bound2 resized bound
radius (a)
Get half-size of bounding box as a vector. A more correct term for this is probably "apothem"

Parameters:

  • a bound2 bound

Returns:

    vec2 Vector spanning center to max point
center (a)
Get center of bounding box

Parameters:

  • a bound2 bound

Returns:

    bound2 Point in center of bound
with_center (a, new)
Move bounding box to new center

Parameters:

  • a bound2 bound
  • new vec2 center

Returns:

    bound2 Bound with same size as input but different center
with_size_centered (a, new)
Resize bounding box from center

Parameters:

  • a bound2 bound
  • new vec2 size

Returns:

    bound2 resized bound
check (a)
Convert possibly-invalid bounding box to valid one

Parameters:

  • a bound2 bound

Returns:

    bound2 bound with all components corrected for min-max property
inset (a, a)
Shrink bounding box with fixed margin

Parameters:

  • a vec2 margin
  • a vec2 margin

Returns:

    bound2 bound with margin subtracted from all edges. May not be valid, consider calling check()
outset (a, a)
Expand bounding box with fixed margin

Parameters:

  • a vec2 margin
  • a vec2 margin

Returns:

    bound2 bound with margin added to all edges. May not be valid, consider calling check()
offset (a, offset)
Offset bounding box

Parameters:

  • a bound2 bound
  • offset vec2

Returns:

    bound2 bound with same size, but position moved by offset
contains (a, point)
Test if point in bound

Parameters:

  • a bound2 bound
  • point vec2 to test

Returns:

    boolean true if point in bounding box
to_string (a)
Return a formatted string.

Parameters:

  • a bound2 bound to be turned into a string

Returns:

    string formatted
generated by LDoc 1.4.6 Last updated 2022-05-07 22:53:35