mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-06 22:09:55 +03:00
Currently including `zh_CN` and `es` which both have very high completion ratios. Others will be added once they reach a significant percentage too. These RST files will be used by godot-docs in place of its `classes` folder after we sync with https://github.com/godotengine/godot-docs/pull/5458. The update workflow is manual for now (example for `zh_CN`): - Build `godotengine/godot` in the branch we currently track (now `3.x`) - Run `godot --doctool -l zh_CN` - Run `cd doc && make rst LANGARG=zh_CN` - Copy `doc/_build/rst/*` to `classes/zh_CN/` here - Make sure to have `classes/zh_CN/index.rst` copied from `docs/classes`
264 lines
15 KiB
ReStructuredText
264 lines
15 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Rect2.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Rect2:
|
|
|
|
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 :ref:`AABB<class_AABB>`.
|
|
|
|
Negative values for :ref:`size<class_Rect2_property_size>` are not supported and will not work for most methods. Use :ref:`abs<class_Rect2_method_abs>` to get a Rect2 with a positive size.
|
|
|
|
Tutoriales
|
|
--------------------
|
|
|
|
- :doc:`Math tutorial index <../tutorials/math/index>`
|
|
|
|
- :doc:`Vector math <../tutorials/math/vector_math>`
|
|
|
|
- :doc:`Advanced vector math <../tutorials/math/vectors_advanced>`
|
|
|
|
Propiedades
|
|
----------------------
|
|
|
|
+-------------------------------+------------------------------------------------+---------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`end<class_Rect2_property_end>` | ``Vector2( 0, 0 )`` |
|
|
+-------------------------------+------------------------------------------------+---------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`position<class_Rect2_property_position>` | ``Vector2( 0, 0 )`` |
|
|
+-------------------------------+------------------------------------------------+---------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`size<class_Rect2_property_size>` | ``Vector2( 0, 0 )`` |
|
|
+-------------------------------+------------------------------------------------+---------------------+
|
|
|
|
Métodos
|
|
--------------
|
|
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_method_Rect2>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_method_Rect2>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` width, :ref:`float<class_float>` height **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`abs<class_Rect2_method_abs>` **(** **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`clip<class_Rect2_method_clip>` **(** :ref:`Rect2<class_Rect2>` b **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`encloses<class_Rect2_method_encloses>` **(** :ref:`Rect2<class_Rect2>` b **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`expand<class_Rect2_method_expand>` **(** :ref:`Vector2<class_Vector2>` to **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`float<class_float>` | :ref:`get_area<class_Rect2_method_get_area>` **(** **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Vector2<class_Vector2>` | :ref:`get_center<class_Rect2_method_get_center>` **(** **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`grow<class_Rect2_method_grow>` **(** :ref:`float<class_float>` by **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`grow_individual<class_Rect2_method_grow_individual>` **(** :ref:`float<class_float>` left, :ref:`float<class_float>` top, :ref:`float<class_float>` right, :ref:`float<class_float>` bottom **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`grow_margin<class_Rect2_method_grow_margin>` **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` by **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_no_area<class_Rect2_method_has_no_area>` **(** **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_point<class_Rect2_method_has_point>` **(** :ref:`Vector2<class_Vector2>` point **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`intersects<class_Rect2_method_intersects>` **(** :ref:`Rect2<class_Rect2>` b, :ref:`bool<class_bool>` include_borders=false **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` **(** :ref:`Rect2<class_Rect2>` rect **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`merge<class_Rect2_method_merge>` **(** :ref:`Rect2<class_Rect2>` b **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Descripciones de Propiedades
|
|
--------------------------------------------------------
|
|
|
|
.. _class_Rect2_property_end:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **end**
|
|
|
|
+-----------+---------------------+
|
|
| *Default* | ``Vector2( 0, 0 )`` |
|
|
+-----------+---------------------+
|
|
|
|
Esquina final. Esto se calcula como ``position + size``. Cambiar esta propiedad cambia el tamaño.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_property_position:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **position**
|
|
|
|
+-----------+---------------------+
|
|
| *Default* | ``Vector2( 0, 0 )`` |
|
|
+-----------+---------------------+
|
|
|
|
Esquina de inicio. Normalmente tiene valores inferiores a :ref:`end<class_Rect2_property_end>`.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_property_size:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **size**
|
|
|
|
+-----------+---------------------+
|
|
| *Default* | ``Vector2( 0, 0 )`` |
|
|
+-----------+---------------------+
|
|
|
|
Size from :ref:`position<class_Rect2_property_position>` to :ref:`end<class_Rect2_property_end>`. Typically, all components are positive.
|
|
|
|
If the size is negative, you can use :ref:`abs<class_Rect2_method_abs>` to fix it.
|
|
|
|
Descripciones de Métodos
|
|
------------------------------------------------
|
|
|
|
.. _class_Rect2_method_Rect2:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)**
|
|
|
|
Construye un ``Rect2`` por posición y tamaño.
|
|
|
|
----
|
|
|
|
- :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` width, :ref:`float<class_float>` height **)**
|
|
|
|
Construye un ``Rect2`` por x, y, ancho y alto.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_abs:
|
|
|
|
- :ref:`Rect2<class_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.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_clip:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **clip** **(** :ref:`Rect2<class_Rect2>` b **)**
|
|
|
|
Devuelve la intersección de esta ``Rect2`` y b.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_encloses:
|
|
|
|
- :ref:`bool<class_bool>` **encloses** **(** :ref:`Rect2<class_Rect2>` b **)**
|
|
|
|
Devuelve ``true`` si este ``Rect2`` encierra completamente otro.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_expand:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **expand** **(** :ref:`Vector2<class_Vector2>` to **)**
|
|
|
|
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))
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_get_area:
|
|
|
|
- :ref:`float<class_float>` **get_area** **(** **)**
|
|
|
|
Devuelve el área de la ``Rect2``.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_get_center:
|
|
|
|
- :ref:`Vector2<class_Vector2>` **get_center** **(** **)**
|
|
|
|
Returns the center of the ``Rect2``, which is equal to :ref:`position<class_Rect2_property_position>` + (:ref:`size<class_Rect2_property_size>` / 2).
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_grow:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **grow** **(** :ref:`float<class_float>` by **)**
|
|
|
|
Devuelve una copia del ``Rect2`` crecido una cantidad dada de unidades hacia todos los lados.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_grow_individual:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **grow_individual** **(** :ref:`float<class_float>` left, :ref:`float<class_float>` top, :ref:`float<class_float>` right, :ref:`float<class_float>` bottom **)**
|
|
|
|
Devuelve una copia del ``Rect2`` crecido una cantidad dada de unidades hacia todos los lados.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_grow_margin:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **grow_margin** **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` by **)**
|
|
|
|
Devuelve una copia del ``Rect2`` crecido una cantidad dada de unidades hacia la dirección del :ref:`Margin<enum_@GlobalScope_Margin>`.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_has_no_area:
|
|
|
|
- :ref:`bool<class_bool>` **has_no_area** **(** **)**
|
|
|
|
Devuelve ``true`` si la ``Rect2`` está plana o vacía.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_has_point:
|
|
|
|
- :ref:`bool<class_bool>` **has_point** **(** :ref:`Vector2<class_Vector2>` point **)**
|
|
|
|
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 :ref:`abs<class_Rect2_method_abs>` to get a positive sized equivalent rectangle to check for contained points.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_intersects:
|
|
|
|
- :ref:`bool<class_bool>` **intersects** **(** :ref:`Rect2<class_Rect2>` b, :ref:`bool<class_bool>` include_borders=false **)**
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_is_equal_approx:
|
|
|
|
- :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Rect2<class_Rect2>` rect **)**
|
|
|
|
Devuelve ``true`` si este ``Rect2`` y ``rect`` son aproximadamente iguales, llamando a ``is_equal_approx`` en cada componente.
|
|
|
|
----
|
|
|
|
.. _class_Rect2_method_merge:
|
|
|
|
- :ref:`Rect2<class_Rect2>` **merge** **(** :ref:`Rect2<class_Rect2>` b **)**
|
|
|
|
Devuelve un ``Rect2`` más grande que contiene este ``Rect2`` y ``b``.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|