mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 17:28:58 +00:00
classref: Sync with current master branch (96cdbbe)
This commit is contained in:
+17
-17
@@ -17,11 +17,11 @@ A 2D axis-aligned bounding box using floating-point coordinates.
|
||||
Description
|
||||
-----------
|
||||
|
||||
The **Rect2** built-in :ref:`Variant<class_Variant>` type represents an axis-aligned rectangle in a 2D space. It is defined by its :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>`, which are :ref:`Vector2<class_Vector2>`. It is frequently used for fast overlap tests (see :ref:`intersects<class_Rect2_method_intersects>`). Although **Rect2** itself is axis-aligned, it can be combined with :ref:`Transform2D<class_Transform2D>` to represent a rotated or skewed rectangle.
|
||||
The **Rect2** built-in :ref:`Variant<class_Variant>` type represents an axis-aligned rectangle in a 2D space. It is defined by its :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>`, which are :ref:`Vector2<class_Vector2>`. It is frequently used for fast overlap tests (see :ref:`intersects()<class_Rect2_method_intersects>`). Although **Rect2** itself is axis-aligned, it can be combined with :ref:`Transform2D<class_Transform2D>` to represent a rotated or skewed rectangle.
|
||||
|
||||
For integer coordinates, use :ref:`Rect2i<class_Rect2i>`. The 3D equivalent to **Rect2** is :ref:`AABB<class_AABB>`.
|
||||
|
||||
\ **Note:** Negative values for :ref:`size<class_Rect2_property_size>` are not supported. With negative size, most **Rect2** methods do not work correctly. Use :ref:`abs<class_Rect2_method_abs>` to get an equivalent **Rect2** with a non-negative size.
|
||||
\ **Note:** Negative values for :ref:`size<class_Rect2_property_size>` are not supported. With negative size, most **Rect2** methods do not work correctly. Use :ref:`abs()<class_Rect2_method_abs>` to get an equivalent **Rect2** with a non-negative size.
|
||||
|
||||
\ **Note:** In a boolean context, a **Rect2** evaluates to ``false`` if both :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>` are zero (equal to :ref:`Vector2.ZERO<class_Vector2_constant_ZERO>`). Otherwise, it always evaluates to ``true``.
|
||||
|
||||
@@ -175,7 +175,7 @@ The origin point. This is usually the top-left corner of the rectangle.
|
||||
|
||||
The rectangle's width and height, starting from :ref:`position<class_Rect2_property_position>`. Setting this value also affects the :ref:`end<class_Rect2_property_end>` point.
|
||||
|
||||
\ **Note:** It's recommended setting the width and height to non-negative values, as most methods in Godot assume that the :ref:`position<class_Rect2_property_position>` is the top-left corner, and the :ref:`end<class_Rect2_property_end>` is the bottom-right corner. To get an equivalent rectangle with non-negative size, use :ref:`abs<class_Rect2_method_abs>`.
|
||||
\ **Note:** It's recommended setting the width and height to non-negative values, as most methods in Godot assume that the :ref:`position<class_Rect2_property_position>` is the top-left corner, and the :ref:`end<class_Rect2_property_end>` is the bottom-right corner. To get an equivalent rectangle with non-negative size, use :ref:`abs()<class_Rect2_method_abs>`.
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
@@ -321,7 +321,7 @@ Returns a copy of this rectangle expanded to align the edges with the given ``to
|
||||
|
||||
:ref:`float<class_float>` **get_area**\ (\ ) |const| :ref:`🔗<class_Rect2_method_get_area>`
|
||||
|
||||
Returns the rectangle's area. This is equivalent to ``size.x * size.y``. See also :ref:`has_area<class_Rect2_method_has_area>`.
|
||||
Returns the rectangle's area. This is equivalent to ``size.x * size.y``. See also :ref:`has_area()<class_Rect2_method_has_area>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -357,7 +357,7 @@ Returns the vertex's position of this rect that's the farthest in the given dire
|
||||
|
||||
:ref:`Rect2<class_Rect2>` **grow**\ (\ amount\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Rect2_method_grow>`
|
||||
|
||||
Returns a copy of this rectangle extended on all sides by the given ``amount``. A negative ``amount`` shrinks the rectangle instead. See also :ref:`grow_individual<class_Rect2_method_grow_individual>` and :ref:`grow_side<class_Rect2_method_grow_side>`.
|
||||
Returns a copy of this rectangle extended on all sides by the given ``amount``. A negative ``amount`` shrinks the rectangle instead. See also :ref:`grow_individual()<class_Rect2_method_grow_individual>` and :ref:`grow_side()<class_Rect2_method_grow_side>`.
|
||||
|
||||
|
||||
.. tabs::
|
||||
@@ -384,7 +384,7 @@ Returns a copy of this rectangle extended on all sides by the given ``amount``.
|
||||
|
||||
:ref:`Rect2<class_Rect2>` **grow_individual**\ (\ left\: :ref:`float<class_float>`, top\: :ref:`float<class_float>`, right\: :ref:`float<class_float>`, bottom\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Rect2_method_grow_individual>`
|
||||
|
||||
Returns a copy of this rectangle with its ``left``, ``top``, ``right``, and ``bottom`` sides extended by the given amounts. Negative values shrink the sides, instead. See also :ref:`grow<class_Rect2_method_grow>` and :ref:`grow_side<class_Rect2_method_grow_side>`.
|
||||
Returns a copy of this rectangle with its ``left``, ``top``, ``right``, and ``bottom`` sides extended by the given amounts. Negative values shrink the sides, instead. See also :ref:`grow()<class_Rect2_method_grow>` and :ref:`grow_side()<class_Rect2_method_grow_side>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -396,7 +396,7 @@ Returns a copy of this rectangle with its ``left``, ``top``, ``right``, and ``bo
|
||||
|
||||
:ref:`Rect2<class_Rect2>` **grow_side**\ (\ side\: :ref:`int<class_int>`, amount\: :ref:`float<class_float>`\ ) |const| :ref:`🔗<class_Rect2_method_grow_side>`
|
||||
|
||||
Returns a copy of this rectangle with its ``side`` extended by the given ``amount`` (see :ref:`Side<enum_@GlobalScope_Side>` constants). A negative ``amount`` shrinks the rectangle, instead. See also :ref:`grow<class_Rect2_method_grow>` and :ref:`grow_individual<class_Rect2_method_grow_individual>`.
|
||||
Returns a copy of this rectangle with its ``side`` extended by the given ``amount`` (see :ref:`Side<enum_@GlobalScope_Side>` constants). A negative ``amount`` shrinks the rectangle, instead. See also :ref:`grow()<class_Rect2_method_grow>` and :ref:`grow_individual()<class_Rect2_method_grow_individual>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -408,7 +408,7 @@ Returns a copy of this rectangle with its ``side`` extended by the given ``amoun
|
||||
|
||||
:ref:`bool<class_bool>` **has_area**\ (\ ) |const| :ref:`🔗<class_Rect2_method_has_area>`
|
||||
|
||||
Returns ``true`` if this rectangle has positive width and height. See also :ref:`get_area<class_Rect2_method_get_area>`.
|
||||
Returns ``true`` if this rectangle has positive width and height. See also :ref:`get_area()<class_Rect2_method_get_area>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -422,7 +422,7 @@ Returns ``true`` if this rectangle has positive width and height. See also :ref:
|
||||
|
||||
Returns ``true`` if the rectangle contains the given ``point``. By convention, points on the right and bottom edges are **not** included.
|
||||
|
||||
\ **Note:** This method is not reliable for **Rect2** with a *negative* :ref:`size<class_Rect2_property_size>`. Use :ref:`abs<class_Rect2_method_abs>` first to get a valid rectangle.
|
||||
\ **Note:** This method is not reliable for **Rect2** with a *negative* :ref:`size<class_Rect2_property_size>`. Use :ref:`abs()<class_Rect2_method_abs>` first to get a valid rectangle.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -455,7 +455,7 @@ Returns the intersection between this rectangle and ``b``. If the rectangles do
|
||||
|
||||
|
||||
|
||||
\ **Note:** If you only need to know whether two rectangles are overlapping, use :ref:`intersects<class_Rect2_method_intersects>`, instead.
|
||||
\ **Note:** If you only need to know whether two rectangles are overlapping, use :ref:`intersects()<class_Rect2_method_intersects>`, instead.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -479,7 +479,7 @@ Returns ``true`` if this rectangle overlaps with the ``b`` rectangle. The edges
|
||||
|
||||
:ref:`bool<class_bool>` **is_equal_approx**\ (\ rect\: :ref:`Rect2<class_Rect2>`\ ) |const| :ref:`🔗<class_Rect2_method_is_equal_approx>`
|
||||
|
||||
Returns ``true`` if this rectangle and ``rect`` are approximately equal, by calling :ref:`Vector2.is_equal_approx<class_Vector2_method_is_equal_approx>` on the :ref:`position<class_Rect2_property_position>` and the :ref:`size<class_Rect2_property_size>`.
|
||||
Returns ``true`` if this rectangle and ``rect`` are approximately equal, by calling :ref:`Vector2.is_equal_approx()<class_Vector2_method_is_equal_approx>` on the :ref:`position<class_Rect2_property_position>` and the :ref:`size<class_Rect2_property_size>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -491,7 +491,7 @@ Returns ``true`` if this rectangle and ``rect`` are approximately equal, by call
|
||||
|
||||
:ref:`bool<class_bool>` **is_finite**\ (\ ) |const| :ref:`🔗<class_Rect2_method_is_finite>`
|
||||
|
||||
Returns ``true`` if this rectangle's values are finite, by calling :ref:`Vector2.is_finite<class_Vector2_method_is_finite>` on the :ref:`position<class_Rect2_property_position>` and the :ref:`size<class_Rect2_property_size>`.
|
||||
Returns ``true`` if this rectangle's values are finite, by calling :ref:`Vector2.is_finite()<class_Vector2_method_is_finite>` on the :ref:`position<class_Rect2_property_position>` and the :ref:`size<class_Rect2_property_size>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -503,7 +503,7 @@ Returns ``true`` if this rectangle's values are finite, by calling :ref:`Vector2
|
||||
|
||||
:ref:`Rect2<class_Rect2>` **merge**\ (\ b\: :ref:`Rect2<class_Rect2>`\ ) |const| :ref:`🔗<class_Rect2_method_merge>`
|
||||
|
||||
Returns a **Rect2** that encloses both this rectangle and ``b`` around the edges. See also :ref:`encloses<class_Rect2_method_encloses>`.
|
||||
Returns a **Rect2** that encloses both this rectangle and ``b`` around the edges. See also :ref:`encloses()<class_Rect2_method_encloses>`.
|
||||
|
||||
.. rst-class:: classref-section-separator
|
||||
|
||||
@@ -522,7 +522,7 @@ Operator Descriptions
|
||||
|
||||
Returns ``true`` if the :ref:`position<class_Rect2_property_position>` or :ref:`size<class_Rect2_property_size>` of both rectangles are not equal.
|
||||
|
||||
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
|
||||
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -536,9 +536,9 @@ Returns ``true`` if the :ref:`position<class_Rect2_property_position>` or :ref:`
|
||||
|
||||
Inversely transforms (multiplies) the **Rect2** by the given :ref:`Transform2D<class_Transform2D>` transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
|
||||
|
||||
\ ``rect * transform`` is equivalent to ``transform.inverse() * rect``. See :ref:`Transform2D.inverse<class_Transform2D_method_inverse>`.
|
||||
\ ``rect * transform`` is equivalent to ``transform.inverse() * rect``. See :ref:`Transform2D.inverse()<class_Transform2D_method_inverse>`.
|
||||
|
||||
For transforming by inverse of an affine transformation (e.g. with scaling) ``transform.affine_inverse() * rect`` can be used instead. See :ref:`Transform2D.affine_inverse<class_Transform2D_method_affine_inverse>`.
|
||||
For transforming by inverse of an affine transformation (e.g. with scaling) ``transform.affine_inverse() * rect`` can be used instead. See :ref:`Transform2D.affine_inverse()<class_Transform2D_method_affine_inverse>`.
|
||||
|
||||
.. rst-class:: classref-item-separator
|
||||
|
||||
@@ -552,7 +552,7 @@ For transforming by inverse of an affine transformation (e.g. with scaling) ``tr
|
||||
|
||||
Returns ``true`` if both :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>` of the rectangles are exactly equal, respectively.
|
||||
|
||||
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
|
||||
\ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx()<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
|
||||
|
||||
.. |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.)`
|
||||
|
||||
Reference in New Issue
Block a user