A two-dimensional bounding box with 32-bit integer precision.
struct
|
Box2I
|
implements
|
IEquatable<Box2I>
|
The coordinates refer to blocks (pixel-is-area semantic).
0 1 2 3 4 5 0 . . . . . . X1 := 1, Y1 := 2 1 . . . . . . 2 . # # # . . X2 := 3, Y2 := 3 3 . # # # . . 4 . . . . . . Width := 3, Height := 2 5 . . . . . .
The serialization helper object for values of Box2I.
public
static
readonly
field
|
Serializer
|
||
type
|
ITypeSerializer<Box2I>
|
An empty bounding box at the coordinate origin.
public
static
readonly
field
|
Empty
|
||
type
|
Box2I
|
An
inverse
bounding
box
that
can
be
used
as
the
initial
value
for
computing
bounds
via
subsequent
calls
to
Grow
.
public
static
readonly
field
|
Inverse
|
||
type
|
Box2I
|
Returns the area of this bounding box.
public
property
|
Area
{
get
}
|
||
type
|
int64
|
||
value
|
The area. |
Remarks:
The
area
will
always
be
0
when
IsEmpty
returns
true
.
Returns the bottom-left corner of this box (inclusive).
public
property
|
BottomLeft
{
get
}
|
||
type
|
Vec2I
|
||
value
|
The bottom-left corner: X1 is stored in X, Y2 is stored in Y. |
Returns the bottom-right corner of this box (inclusive).
public
property
|
BottomRight
{
get
}
|
||
type
|
Vec2I
|
||
value
|
The bottom-right corner: X2 is stored in X, Y2 is stored in Y. |
public
property
|
Center
{
get
}
|
||
type
|
Vec2I
|
||
value
|
Returns the extends of this box along the Y-axis.
public
property
|
Height
{
get
}
|
||
type
|
int32
|
||
value
|
The box height. |
Is this bounding box empty?
public
property
|
IsEmpty
{
get
}
|
||
type
|
bool
|
||
value
|
true
if
this
bounding
box
is
empty,
false
if
not. |
Returns the size of this box.
public
property
|
Size
{
get
}
|
||
type
|
Vec2I
|
||
value
|
The box size: The Width is stored in X, the Height in Y. |
Returns the top-left corner of this box (inclusive).
public
property
|
TopLeft
{
get
}
|
||
type
|
Vec2I
|
||
value
|
The top-left corner: X1 is stored in X, Y1 is stored in Y. |
Returns the top-right corner of this box (inclusive).
public
property
|
TopRight
{
get
}
|
||
type
|
Vec2I
|
||
value
|
The top-right corner: X2 is stored in X, Y1 is stored in Y. |
Returns the extends of this box along the X-axis.
public
property
|
Width
{
get
}
|
||
type
|
int32
|
||
value
|
The box width. |
X-coordinate of minimum corner of bounding box.
public
readonly
field
|
X1
|
||
type
|
int32
|
X-coordinate of maximum corner of bounding box.
public
readonly
field
|
X2
|
||
type
|
int32
|
Y-coordinate of minimum corner of bounding box.
public
readonly
field
|
Y1
|
||
type
|
int32
|
Y-coordinate of maximum corner of bounding box.
public
readonly
field
|
Y2
|
||
type
|
int32
|
Checks the intersection between this bounding box and the given one.
[Pure]
|
||||
public
method
|
CheckIntersection
(Box2I box)
|
|||
type
|
int32
|
|||
params
|
box
|
The bounding box. | ||
returns
|
-1
if
the
bounding
boxes
do
not
overlap,
1
if
box
fully
contains
this
bounding
box
and
0
if
both
bounding
boxes
overlap
without
containing
each
other.
|
[Pure]
|
||||
public
method
|
Clamp
(Vec2I v)
|
|||
type
|
Vec2I
|
|||
params
|
v
|
[Pure]
|
||||
public
method
|
Clamp
(int32 x,
int32 y)
|
|||
type
|
Vec2I
|
|||
params
|
x
|
|||
y
|
Computes the overlap of this bounding box and the given one.
[Pure]
|
||||
public
method
|
ComputeOverlap
(Box2I box)
|
|||
type
|
int64
|
|||
params
|
box
|
Second bounding box. | ||
returns
|
|
The amount of overlap (i.e. the volume of the intersection). |
Checks if this box contains the given point.
[Pure]
|
||||
public
method
|
Contains
(Vec2I xy)
|
|||
type
|
bool
|
|||
params
|
xy
|
The point coordinates. | ||
returns
|
true
if
this
box
contains
the
point,
false
if
not. |
Checks if this box contains the given box.
[Pure]
|
||||
public
method
|
Contains
(Box2I box)
|
|||
type
|
bool
|
|||
params
|
box
|
The other box. | ||
returns
|
true
if
this
box
fully
contains
the
given
box,
false
if
not.
|
Checks if this box contains the given point.
[Pure]
|
||||
public
method
|
Contains
(int32 x,
int32 y)
|
|||
type
|
bool
|
|||
params
|
x
|
The point X-coordinate. | ||
y
|
The point Y-coordinate. | |||
returns
|
true
if
this
box
contains
the
point,
false
if
not. |
Checks if this box and the given box are disjoint (i.e. do not intersect).
[Pure]
|
||||
public
method
|
Disjoint
(Box2I box)
|
|||
type
|
bool
|
|||
params
|
box
|
The other box. | ||
returns
|
true
if
this
box
and
the
given
box
are
disjoint,
false
if
not.
|
[Pure]
|
||||
public
method
|
Equals
(Box2I other)
|
|||
type
|
bool
|
|||
params
|
other
|
Creates a new instance of Box2I from the given corner points.
[Pure]
|
||||
public
static
method
|
FromPoints
(Vec2I a,
Vec2I b)
|
|||
type
|
Box2I
|
|||
params
|
a
|
First corner point (inclusive). | ||
b
|
Second corner point (inclusive). | |||
returns
|
The bounding box. |
Creates a new instance of Box2I from the given corner points.
[Pure]
|
||||
public
static
method
|
FromPoints
(int32 x1,
int32 y1,
int32 x2,
int32 y2)
|
|||
type
|
Box2I
|
|||
params
|
x1
|
X-coordinate of first corner point (inclusive). | ||
y1
|
Y-coordinate of first corner point (inclusive). | |||
x2
|
X-coordinate of second corner point (inclusive). | |||
y2
|
Y-coordinate of second corner point (inclusive). | |||
returns
|
The bounding box. |
Creates a new instance of Box2I from the given rectangle.
[Pure]
|
||||
public
static
method
|
FromRect
(int32 x,
int32 y,
int32 width,
int32 height)
|
|||
type
|
Box2I
|
|||
params
|
x
|
X-coordinate of top-left corner of rectangle. | ||
y
|
Y-coordinate of top-left corner of rectangle. | |||
width
|
Width of rectangle. | |||
height
|
Height of rectangle. | |||
returns
|
The bounding box. |
Enlarges the extends of this box so that it covers the given box.
public
method
|
Grow
(Box2I box)
|
||
type
|
Box2I
|
||
params
|
box
|
To other box. | |
returns
|
The resulting box. |
Enlarges the extends of this box so that it covers the given point.
public
method
|
Grow
(Vec2I v)
|
||
type
|
Box2I
|
||
params
|
v
|
Coordinates of point to cover. | |
returns
|
The resulting box. |
Enlarges the extends of this box so that it covers the given point.
public
method
|
Grow
(int32 x,
int32 y)
|
||
type
|
Box2I
|
||
params
|
x
|
X-coordinate of point to cover. | |
y
|
Y-coordinate of point to cover. | ||
returns
|
The resulting box. |
Computes the intersection of the given bounding box and this one.
[Pure]
|
||||
public
method
|
Intersect
(Box2I box)
|
|||
type
|
Box2I
|
|||
params
|
box
|
The bounding box. | ||
returns
|
The resulting bounding box. |
public
method
|
Pad
(int32 top,
int32 left,
int32 bottom,
int32 right)
|
||
type
|
Box2I
|
||
params
|
top
|
||
left
|
|||
bottom
|
|||
right
|
Returns a simple string representation of this bounding box.
[Pure]
|
||||
public
override
method
|
ToString
()
|
|||
type
|
string
|
|||
returns
|
|
The string representation. |
Translates this bounding box.
[Pure]
|
||||
public
method
|
Translate
(int32 x,
int32 y)
|
|||
type
|
Box2I
|
|||
params
|
x
|
Translation amount along X-axis. | ||
y
|
Translation amount along Y-axis. | |||
returns
|
The translated bounding box. |