planar.BoundingBox – Bounding Boxes — Planar v0.4 documentation

### Navigation

- index
- modules |
- next |
- previous |
- Planar v0.4 documentation »

# `planar.BoundingBox` – Bounding Boxes

class `planar.` `BoundingBox`(points)

  An axis-aligned immutable rectangular shape described by two points that define the minimum and maximum corners.

  Parameters: | points – Iterable containing one or more `Vec2` objects.

  `almost_equals`(other)

    Return True if this bounding box is approximately equal to another box, within precision limits.

  `contains_point`(point)

    Return True if the box contains the specified point.

    Parameters: | other (`Vec2`) – A point vector
    Return type: | bool

  `fit`(shape)

    Create a new shape by translating and scaling shape so that it fits in this bounding box. The shape is scaled evenly so that it retains the same aspect ratio.

    Parameters: | shape – A transformable shape with a bounding box.

  classmethod `from_center`(center, width, height)

    Create a bounding box centered at a particular point.

    Parameters: | center (`Vec2`) – Center point width (float) – Box width. height (float) – Box height.

  classmethod `from_points`(points)

    Create a bounding box that encloses all of the specified points.

  classmethod `from_shapes`(shapes)

    Creating a bounding box that completely encloses all of the shapes provided.

  `inflate`(amount)

    Return a new box resized from this one. The new box has its size changed by the specified amount, but remains centered on the same point.

    Parameters: | amount (float or `Vec2`) – The quantity to add to the width and height of the box. A scalar value changes both the width and height equally. A vector will change the width and height independently. Negative values reduce the size accordingly.

  `to_polygon`()

    Return a rectangular `Polygon` object with the same vertices as the bounding box.

    Return type: | `Polygon`

  `bounding_box`

    The bounding box for this shape. For a BoundingBox instance, this is always itself.

  `center`

    The center point of the box.

  `height`

    The height of the box.

  `is_empty`

    True if the box has zero area.

  `max_point`

    The maximum corner point for the shape. This is the corner with the largest x and y value.

  `min_point`

    The minimum corner point for the shape. This is the corner with the smallest x and y value.

  `width`

    The width of the box.

### Navigation

- index
- modules |
- next |
- previous |
- Planar v0.4 documentation »