A 2D bounding box often used for determining Object bounding area.

Bounds holds min/max coordinates of bounding box instead of it's position and size.

See also:

Static methods

staticinlinefromPoints(min:Point, max:Point):Bounds

Returns a new Bounds instance from given min/max Points.

staticinlinefromValues(x0:Float, y0:Float, width:Float, height:Float):Bounds

Returns a new Bounds instance from given rectangle.

Parameters:

x

Rectangle horizontal position.

y

Rectangle vertical position.

width

Rectangle width.

height

Rectangle height.

Constructor

inlinenew()

Create new empty Bounds instance.

Variables

height:Float

Height of the bounding box. Equivalent of yMax - yMin.

width:Float

Width of the bounding box. Equivalent of xMax - xMin.

x:Float

X-axis position of the bounding box top-left corner. Modifying it alters both Bounds.xMin and Bounds.xMax.

xMax:Float

X-axis right-most bounding box point.

xMin:Float

X-axis left-most bounding box point.

y:Float

Y-axis position of the bounding box top-left corner. Modifying it alters both Bounds.yMin and Bounds.yMax.

yMax:Float

Y-axis bottom-most bounding box point.

yMin:Float

Y-axis top-most bounding box point.

Methods

inlineaddBounds(b:Bounds):Void

Adds Bounds b to the Bounds, expanding min/max when necessary.

inlineaddPoint(p:Point):Void

Adds the Point p to the bounding box, expanding min/max when necessary.

inlineaddPos(x:Float, y:Float):Void

Adds the x and y position to the bounding box, expanding min/max when necessary.

inlineall():Void

Sets the bounding box to cover maximum area (-1e20...1e20).

inlineclone():Bounds

Returns new copy of this Bounds instance.

inlinecontains(p:Point):Bool

Tests if the Point p is inside the bounding box.

inlinedistance(p:Point):Float

Returns the distance betwen the point and the bounds. Or 0 if the point is inside the bounds.

inlinedistanceSq(p:Point):Float

Same as distance but does not perform sqrt

inlinedoIntersect(b:Bounds):Void

Sets the bounding box min/max values to a result of the intersection between this Bounds and the given Bounds b.

See Bounds.intersection to get new instance of Bounds as intersection result.

inlinedoUnion(b:Bounds):Void

Sets this bounding box min/max values to a result of combining this Bounds and the given Bounds b.

Equivalent of Bounds.addBounds.

inlineempty():Void

Clears bounding box into an empty state.

inlinegetCenter():Point

Returns a new Point containing the center coordinate of the bounding box.

inlinegetMax():Point

Returns a new Point containing Bounds.xMax and Bounds.yMax.

inlinegetMin():Point

Returns a new Point containing Bounds.xMin and Bounds.yMin.

inlinegetSize():Point

Returns a new Point containing size of the bounding box.

intersection(b:Bounds):Bounds

Returns a new Bounds instance containing intersection results of this Bounds and the given Bounds b.

inlineintersects(b:Bounds):Bool

Tests if this Bounds instance intersects with given b Bounds.

inlineisEmpty():Bool

Tests if bounding box is empty. Bounds are considered empty when either Bounds.xMax is less than or equals to Bounds.xMin or Bounds.yMax is less than or equals to Bounds.yMin.

load(b:Bounds):Void

Copies the min/max values from the given Bounds b to this Bounds.

inlineoffset(dx:Float, dy:Float):Void

Moves entire bounding box by dx, dy.

rotate(angle:Float):Void

Rotates the bounding box around 0,0 point by given angle and sets min/max to the new rotated boundaries.

scaleCenter(v:Float):Void

Scales the min/max values relative the current bounding box center point.

inlinescalePivot(v:Float):Void

Scales the min/max values relative to 0,0 coordinate.

inlineset(x:Float, y:Float, width:Float, height:Float):Void

Sets the bounding box from the given rectangle.

Parameters:

x

Rectangle top-left corner horizontal position.

y

Rectangle top-left corner vertical position.

width

Rectangle width.

height

Rectangle height.

inlinesetMax(p:Point):Void

Sets the Bounds.xMax and Bounds.yMax to values in the given Point p.

inlinesetMin(p:Point):Void

Sets the Bounds.xMin and Bounds.yMin to values in the given Point p.

inlinetoCircle():Circle

Returns the bounding circle which includes all the bounds.

@:value({ scale : 1. })inlinetoIBounds(scale:Float = 1.):IBounds

Converts bounding box to integer bounding box scaled by provided scalar scale (rounded down for min and up for max).

union(b:Bounds):Bounds

Returns a new Bounds instance containing union of this Bounds and the given Bounds b.