The **Box2**
class
describes a 2D rectangular region using integer coordinates. The
Box2 class provides methods that return individual coordinates of
the box, scale and translate it, retrieve its center, modify its
size, and determine if points are inside the box. Box2 values are
primarily used in the viewport graphics methods described in
Viewport Drawing
Methods.

**Constructors**

**Box2**

Constructs a Box2 with the
upper left corner at **[x,y]**
with
width **w**
and
height **h**.

**Box2**

Constructs a Box2 object from the specified corners.

**Properties**

**x**
:
Integer

**y**
:
Integer

**w**
:
Integer

**h**
:
Integer

**left**
:
Integer, alias of x property

**right**
:
Integer

**top**
:
Integer, alias of y property

**bottom**
:
Integer

**center**
:
Point2, read-only

The **right**
property is calculated
as **right
= x + w - 1**. The
**bottom**
property is calculated
as **bottom
= y + h - 1**. Setting the
**right**
or **bottom**
property will normally
change the **w**
and **h**
properties, respectively.
However, if **right**
is
set less than **left**, the
**right**
and **left**
values will be swapped,
and then the new value will be used as the **left**
value. Likewise, if
**bottom**
is
set less than **top**, the
**bottom**
and **top**
values will be swapped,
and then the new value will be used as the **top**
value.

**Operators**

Standard comparison operators. Two Box2 values are equal if all of their component values are equal.

**scale**

Scales the coordinates of the box about the center of the box.

**translate**

Translates the coordinates of the box by the distance specified.

**contains**

Determines if the point2
value is contained within the Box2. Returns **true**
if
the point is inside the Box2 or on the Box2 edge; otherwise
**false**.

**rectify**

Adjusts the coordinates of
the box such that **top**
< **bottom**
and **left**
< **right**.

**empty**

Sets the Box2 to a special "empty" value.

**isEmpty**

Returns
**true**
if
the Box2 contains the special "empty" value, **false**
otherwise.