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¶
2D axis-aligned bounding box.
Descripción¶
Rect2
consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
It uses floating-point coordinates.
The 3D counterpart to Rect2
is AABB.
Negative values for size are not supported and will not work for most methods. Use abs to get a Rect2 with a positive size.
Tutoriales¶
Propiedades¶
|
||
|
||
|
Métodos¶
abs ( ) |
|
get_area ( ) |
|
get_center ( ) |
|
grow_individual ( float left, float top, float right, float bottom ) |
|
grow_margin ( int margin, float by ) |
|
has_no_area ( ) |
|
intersects ( Rect2 b, bool include_borders=false ) |
|
is_equal_approx ( Rect2 rect ) |
|
Descripciones de Propiedades¶
Vector2 end
Default |
|
Esquina final. Esto se calcula como position + size
. Cambiar esta propiedad cambia el tamaño.
Vector2 position
Default |
|
Esquina de inicio. Normalmente tiene valores inferiores a end.
Vector2 size
Default |
|
Size from position to end. Typically, all components are positive.
If the size is negative, you can use abs to fix it.
Descripciones de Métodos¶
Construye un Rect2
por posición y tamaño.
Construye un Rect2
por x, y, ancho y alto.
Rect2 abs ( )
Devuelve una Rect2
con posición y área equivalentes, modificada de manera que la esquina superior izquierda es el origen y width
y height
son positivos.
Devuelve la intersección de esta Rect2
y b.
Devuelve true
si este Rect2
encierra completamente otro.
Returns a copy of this Rect2
expanded to include a given point.
Example:
# position (-3, 2), size (1, 1)
var rect = Rect2(Vector2(-3, 2), Vector2(1, 1))
# position (-3, -1), size (3, 4), so we fit both rect and Vector2(0, -1)
var rect2 = rect.expand(Vector2(0, -1))
float get_area ( )
Devuelve el área de la Rect2
.
Vector2 get_center ( )
Returns the center of the Rect2
, which is equal to position + (size / 2).
Devuelve una copia del Rect2
crecido una cantidad dada de unidades hacia todos los lados.
Devuelve una copia del Rect2
crecido una cantidad dada de unidades hacia todos los lados.
Devuelve una copia del Rect2
crecido una cantidad dada de unidades hacia la dirección del Margin.
bool has_no_area ( )
Devuelve true
si la Rect2
está plana o vacía.
Returns true
if the Rect2
contains a point. By convention, the right and bottom edges of the Rect2
are considered exclusive, so points on these edges are not included.
Note: This method is not reliable for Rect2
with a negative size. Use abs to get a positive sized equivalent rectangle to check for contained points.
Devuelve true
si la Rect2
se superpone con b
(es decir, tienen al menos un punto en común).
Si include_borders
es true
, también se considerará que se superponen si sus bordes se tocan, incluso sin intersección.
Devuelve true
si este Rect2
y rect
son aproximadamente iguales, llamando a is_equal_approx
en cada componente.
Devuelve un Rect2
más grande que contiene este Rect2
y b
.