Value > Basic Data Values > Box2 Values |
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.
Constructs a Box2 with the upper left corner at [x,y] with width w and height h .
Constructs a Box2 object from the specified corners.
<Box2>.x: Integer <Box2>.y: Integer <Box2>.w: Integer <Box2>.h: Integer <Box2>.left: Integer, alias of x property <Box2>.right: Integer <Box2>.top: Integer, alias of y property <Box2>.bottom: Integer <Box2>.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.
Standard comparison operators. Two Box2 values are equal if all of their component values are equal.
Scales the coordinates of the box about the center of the box.
Translates the coordinates of the box by the distance specified.
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 .
Adjusts the coordinates of the box such that top < bottom and left < right .
Sets the Box2 to a special "empty" value.
Returns true if the Box2 contains the special "empty" value, false otherwise.