diff options
Diffstat (limited to 'doc/classes/Rect2.xml')
-rw-r--r-- | doc/classes/Rect2.xml | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 01bec10ed8..e4b66a9d53 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Rect2" version="4.0"> +<class name="Rect2" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> <brief_description> 2D axis-aligned bounding box using floating point coordinates. </brief_description> @@ -7,11 +7,12 @@ [Rect2] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. It uses floating-point coordinates. If you need integer coordinates, use [Rect2i] instead. The 3D counterpart to [Rect2] is [AABB]. + Negative values for [member size] are not supported and will not work for most methods. Use [method abs] to get a Rect2 with a positive size. </description> <tutorials> - <link title="Math documentation index">https://docs.godotengine.org/en/latest/tutorials/math/index.html</link> - <link title="Vector math">https://docs.godotengine.org/en/latest/tutorials/math/vector_math.html</link> - <link title="Advanced vector math">https://docs.godotengine.org/en/latest/tutorials/math/vectors_advanced.html</link> + <link title="Math documentation index">$DOCS_URL/tutorials/math/index.html</link> + <link title="Vector math">$DOCS_URL/tutorials/math/vector_math.html</link> + <link title="Advanced vector math">$DOCS_URL/tutorials/math/vectors_advanced.html</link> </tutorials> <constructors> <constructor name="Rect2"> @@ -71,13 +72,28 @@ <return type="Rect2" /> <argument index="0" name="to" type="Vector2" /> <description> - Returns this [Rect2] expanded to include a given point. + Returns a copy of this [Rect2] expanded to include a given point. + [b]Example:[/b] + [codeblocks] + [gdscript] + # 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)) + [/gdscript] + [csharp] + # position (-3, 2), size (1, 1) + var rect = new Rect2(new Vector2(-3, 2), new Vector2(1, 1)); + # position (-3, -1), size (3, 4), so we fit both rect and Vector2(0, -1) + var rect2 = rect.Expand(new Vector2(0, -1)); + [/csharp] + [/codeblocks] </description> </method> <method name="get_area" qualifiers="const"> <return type="float" /> <description> - Returns the area of the [Rect2]. + Returns the area of the [Rect2]. See also [method has_no_area]. </description> </method> <method name="get_center" qualifiers="const"> @@ -114,14 +130,16 @@ <method name="has_no_area" qualifiers="const"> <return type="bool" /> <description> - Returns [code]true[/code] if the [Rect2] is flat or empty. + Returns [code]true[/code] if the [Rect2] is flat or empty, [code]false[/code] otherwise. See also [method get_area]. + [b]Note:[/b] If the [Rect2] has a negative size and is not flat or empty, [method has_no_area] will return [code]true[/code]. </description> </method> <method name="has_point" qualifiers="const"> <return type="bool" /> <argument index="0" name="point" type="Vector2" /> <description> - Returns [code]true[/code] if the [Rect2] contains a point. + Returns [code]true[/code] 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 [b]not[/b] included. + [b]Note:[/b] This method is not reliable for [Rect2] with a [i]negative size[/i]. Use [method abs] to get a positive sized equivalent rectangle to check for contained points. </description> </method> <method name="intersection" qualifiers="const"> @@ -171,30 +189,25 @@ <operators> <operator name="operator !="> <return type="bool" /> - <description> - </description> - </operator> - <operator name="operator !="> - <return type="bool" /> <argument index="0" name="right" type="Rect2" /> <description> + Returns [code]true[/code] if the rectangles are not equal. + [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. </description> </operator> <operator name="operator *"> <return type="Rect2" /> <argument index="0" name="right" type="Transform2D" /> <description> - </description> - </operator> - <operator name="operator =="> - <return type="bool" /> - <description> + Inversely transforms (multiplies) the [Rect2] by the given [Transform2D] transformation matrix. </description> </operator> <operator name="operator =="> <return type="bool" /> <argument index="0" name="right" type="Rect2" /> <description> + Returns [code]true[/code] if the rectangles are exactly equal. + [b]Note:[/b] Due to floating-point precision errors, consider using [method is_equal_approx] instead, which is more reliable. </description> </operator> </operators> |