BoundingBox class

A class representing a bounding box which can optionally have defined minimum and maximum X and Y coordinates.

This class can be used to represent a rectangular area in a coordinate system, where the bounds can be either fixed or flexible. It includes methods for merging multiple bounding boxes and calculating fractional positions within the bounds.

Constructors

BoundingBox({double? minX, double? maxX, double? minY, double? maxY})
Constructs a BoundingBox with specified minimum and maximum coordinates.
const
BoundingBox.flexible()
Creates a BoundingBox with no defined bounds.
const
BoundingBox.merge(Iterable<BoundingBox> boxes)
Creates a new BoundingBox that encompasses all the bounding boxes in the provided iterable.
factory
BoundingBox.point({double? x, double? y})
Creates a BoundingBox representing a single point in the coordinate system.
const
BoundingBox.x({double? min, double? max})
Constructs a BoundingBox that is only bounded on the X-axis.
const
BoundingBox.y({double? min, double? max})
Constructs a BoundingBox that is only bounded on the Y-axis.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
maxX double?
The maximum X coordinate of the bounding box. Can be null for a flexible bounding box.
final
maxY double?
The maximum Y coordinate of the bounding box. Can be null for a flexible bounding box.
final
minX double?
The minimum X coordinate of the bounding box. Can be null for a flexible bounding box.
final
minY double?
The minimum Y coordinate of the bounding box. Can be null for a flexible bounding box.
final
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited

Methods

getFractionX(double x) double
Returns the fractional X position of a given X coordinate within the bounds of this BoundingBox. Throws UnboundedError if X bounds are not set.
getFractionY(double y) double
Returns the fractional Y position of a given Y coordinate within the bounds of this BoundingBox. Throws UnboundedError if Y bounds are not set.
mergeWith(BoundingBox other) BoundingBox
Merges this BoundingBox with another BoundingBox, resulting in a new BoundingBox that encompasses both.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited