Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Rect2¶
A 2D axis-aligned bounding box using floating-point coordinates.
Description¶
The Rect2 built-in Variant type represents an axis-aligned rectangle in a 2D space. It is defined by its position and size, which are Vector2. It is frequently used for fast overlap tests (see intersects). Although Rect2 itself is axis-aligned, it can be combined with Transform2D to represent a rotated or skewed rectangle.
For integer coordinates, use Rect2i. The 3D equivalent to Rect2 is AABB.
Note: Negative values for size are not supported. With negative size, most Rect2 methods do not work correctly. Use abs to get an equivalent Rect2 with a non-negative size.
Note: In a boolean context, a Rect2 evaluates to false
if both position and size are zero (equal to Vector2.ZERO). Otherwise, it always evaluates to true
.
Примітка
There are notable differences when using this API with C#. See Відмінності API C# в GDScript for more information.
Tutorials¶
Properties¶
|
||
|
||
|
Constructors¶
Rect2 ( ) |
|
Methods¶
abs ( ) const |
|
get_area ( ) const |
|
get_center ( ) const |
|
grow_individual ( float left, float top, float right, float bottom ) const |
|
has_area ( ) const |
|
intersection ( Rect2 b ) const |
|
intersects ( Rect2 b, bool include_borders=false ) const |
|
is_equal_approx ( Rect2 rect ) const |
|
is_finite ( ) const |
|