class_rect2.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Rect2.xml.
  6. .. _class_Rect2:
  7. Rect2
  8. =====
  9. A 2D axis-aligned bounding box using floating-point coordinates.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. 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.
  14. For integer coordinates, use :ref:`Rect2i<class_Rect2i>`. The 3D equivalent to **Rect2** is :ref:`AABB<class_AABB>`.
  15. \ **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.
  16. \ **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``.
  17. .. note::
  18. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  19. .. rst-class:: classref-introduction-group
  20. Tutorials
  21. ---------
  22. - :doc:`Math documentation index <../tutorials/math/index>`
  23. - :doc:`Vector math <../tutorials/math/vector_math>`
  24. - :doc:`Advanced vector math <../tutorials/math/vectors_advanced>`
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +-------------------------------+------------------------------------------------+-------------------+
  31. | :ref:`Vector2<class_Vector2>` | :ref:`end<class_Rect2_property_end>` | ``Vector2(0, 0)`` |
  32. +-------------------------------+------------------------------------------------+-------------------+
  33. | :ref:`Vector2<class_Vector2>` | :ref:`position<class_Rect2_property_position>` | ``Vector2(0, 0)`` |
  34. +-------------------------------+------------------------------------------------+-------------------+
  35. | :ref:`Vector2<class_Vector2>` | :ref:`size<class_Rect2_property_size>` | ``Vector2(0, 0)`` |
  36. +-------------------------------+------------------------------------------------+-------------------+
  37. .. rst-class:: classref-reftable-group
  38. Constructors
  39. ------------
  40. .. table::
  41. :widths: auto
  42. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_constructor_Rect2>` **(** **)** |
  44. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_constructor_Rect2>` **(** :ref:`Rect2<class_Rect2>` from **)** |
  46. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_constructor_Rect2>` **(** :ref:`Rect2i<class_Rect2i>` from **)** |
  48. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_constructor_Rect2>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)** |
  50. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_constructor_Rect2>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` width, :ref:`float<class_float>` height **)** |
  52. +---------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. .. rst-class:: classref-reftable-group
  54. Methods
  55. -------
  56. .. table::
  57. :widths: auto
  58. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Rect2<class_Rect2>` | :ref:`abs<class_Rect2_method_abs>` **(** **)** |const| |
  60. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`encloses<class_Rect2_method_encloses>` **(** :ref:`Rect2<class_Rect2>` b **)** |const| |
  62. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Rect2<class_Rect2>` | :ref:`expand<class_Rect2_method_expand>` **(** :ref:`Vector2<class_Vector2>` to **)** |const| |
  64. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`float<class_float>` | :ref:`get_area<class_Rect2_method_get_area>` **(** **)** |const| |
  66. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Vector2<class_Vector2>` | :ref:`get_center<class_Rect2_method_get_center>` **(** **)** |const| |
  68. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Rect2<class_Rect2>` | :ref:`grow<class_Rect2_method_grow>` **(** :ref:`float<class_float>` amount **)** |const| |
  70. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :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 **)** |const| |
  72. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Rect2<class_Rect2>` | :ref:`grow_side<class_Rect2_method_grow_side>` **(** :ref:`int<class_int>` side, :ref:`float<class_float>` amount **)** |const| |
  74. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`has_area<class_Rect2_method_has_area>` **(** **)** |const| |
  76. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`has_point<class_Rect2_method_has_point>` **(** :ref:`Vector2<class_Vector2>` point **)** |const| |
  78. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`Rect2<class_Rect2>` | :ref:`intersection<class_Rect2_method_intersection>` **(** :ref:`Rect2<class_Rect2>` b **)** |const| |
  80. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | :ref:`bool<class_bool>` | :ref:`intersects<class_Rect2_method_intersects>` **(** :ref:`Rect2<class_Rect2>` b, :ref:`bool<class_bool>` include_borders=false **)** |const| |
  82. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` **(** :ref:`Rect2<class_Rect2>` rect **)** |const| |
  84. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`is_finite<class_Rect2_method_is_finite>` **(** **)** |const| |
  86. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | :ref:`Rect2<class_Rect2>` | :ref:`merge<class_Rect2_method_merge>` **(** :ref:`Rect2<class_Rect2>` b **)** |const| |
  88. +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. .. rst-class:: classref-reftable-group
  90. Operators
  91. ---------
  92. .. table::
  93. :widths: auto
  94. +---------------------------+-----------------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`operator !=<class_Rect2_operator_neq_Rect2>` **(** :ref:`Rect2<class_Rect2>` right **)** |
  96. +---------------------------+-----------------------------------------------------------------------------------------------------------------+
  97. | :ref:`Rect2<class_Rect2>` | :ref:`operator *<class_Rect2_operator_mul_Transform2D>` **(** :ref:`Transform2D<class_Transform2D>` right **)** |
  98. +---------------------------+-----------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`operator ==<class_Rect2_operator_eq_Rect2>` **(** :ref:`Rect2<class_Rect2>` right **)** |
  100. +---------------------------+-----------------------------------------------------------------------------------------------------------------+
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Property Descriptions
  105. ---------------------
  106. .. _class_Rect2_property_end:
  107. .. rst-class:: classref-property
  108. :ref:`Vector2<class_Vector2>` **end** = ``Vector2(0, 0)``
  109. The ending point. This is usually the bottom-right corner of the rectangle, and is equivalent to ``position + size``. Setting this point affects the :ref:`size<class_Rect2_property_size>`.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_Rect2_property_position:
  113. .. rst-class:: classref-property
  114. :ref:`Vector2<class_Vector2>` **position** = ``Vector2(0, 0)``
  115. The origin point. This is usually the top-left corner of the rectangle.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_Rect2_property_size:
  119. .. rst-class:: classref-property
  120. :ref:`Vector2<class_Vector2>` **size** = ``Vector2(0, 0)``
  121. 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.
  122. \ **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>`.
  123. .. rst-class:: classref-section-separator
  124. ----
  125. .. rst-class:: classref-descriptions-group
  126. Constructor Descriptions
  127. ------------------------
  128. .. _class_Rect2_constructor_Rect2:
  129. .. rst-class:: classref-constructor
  130. :ref:`Rect2<class_Rect2>` **Rect2** **(** **)**
  131. Constructs a **Rect2** with its :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>` set to :ref:`Vector2.ZERO<class_Vector2_constant_ZERO>`.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. rst-class:: classref-constructor
  135. :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`Rect2<class_Rect2>` from **)**
  136. Constructs a **Rect2** as a copy of the given **Rect2**.
  137. .. rst-class:: classref-item-separator
  138. ----
  139. .. rst-class:: classref-constructor
  140. :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`Rect2i<class_Rect2i>` from **)**
  141. Constructs a **Rect2** from a :ref:`Rect2i<class_Rect2i>`.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. rst-class:: classref-constructor
  145. :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)**
  146. Constructs a **Rect2** by ``position`` and ``size``.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. rst-class:: classref-constructor
  150. :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 **)**
  151. Constructs a **Rect2** by setting its :ref:`position<class_Rect2_property_position>` to (``x``, ``y``), and its :ref:`size<class_Rect2_property_size>` to (``width``, ``height``).
  152. .. rst-class:: classref-section-separator
  153. ----
  154. .. rst-class:: classref-descriptions-group
  155. Method Descriptions
  156. -------------------
  157. .. _class_Rect2_method_abs:
  158. .. rst-class:: classref-method
  159. :ref:`Rect2<class_Rect2>` **abs** **(** **)** |const|
  160. Returns a **Rect2** equivalent to this rectangle, with its width and height modified to be non-negative values, and with its :ref:`position<class_Rect2_property_position>` being the top-left corner of the rectangle.
  161. .. tabs::
  162. .. code-tab:: gdscript
  163. var rect = Rect2(25, 25, -100, -50)
  164. var absolute = rect.abs() # absolute is Rect2(-75, -25, 100, 50)
  165. .. code-tab:: csharp
  166. var rect = new Rect2(25, 25, -100, -50);
  167. var absolute = rect.Abs(); // absolute is Rect2(-75, -25, 100, 50)
  168. \ **Note:** It's recommended to use this method when :ref:`size<class_Rect2_property_size>` is negative, as most other 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.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_Rect2_method_encloses:
  172. .. rst-class:: classref-method
  173. :ref:`bool<class_bool>` **encloses** **(** :ref:`Rect2<class_Rect2>` b **)** |const|
  174. Returns ``true`` if this rectangle *completely* encloses the ``b`` rectangle.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_Rect2_method_expand:
  178. .. rst-class:: classref-method
  179. :ref:`Rect2<class_Rect2>` **expand** **(** :ref:`Vector2<class_Vector2>` to **)** |const|
  180. Returns a copy of this rectangle expanded to align the edges with the given ``to`` point, if necessary.
  181. .. tabs::
  182. .. code-tab:: gdscript
  183. var rect = Rect2(0, 0, 5, 2)
  184. rect = rect.expand(Vector2(10, 0)) # rect is Rect2(0, 0, 10, 2)
  185. rect = rect.expand(Vector2(-5, 5)) # rect is Rect2(-5, 0, 10, 5)
  186. .. code-tab:: csharp
  187. var rect = new Rect2(0, 0, 5, 2);
  188. rect = rect.Expand(new Vector2(10, 0)); // rect is Rect2(0, 0, 10, 2)
  189. rect = rect.Expand(new Vector2(-5, 5)); // rect is Rect2(-5, 0, 10, 5)
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_Rect2_method_get_area:
  193. .. rst-class:: classref-method
  194. :ref:`float<class_float>` **get_area** **(** **)** |const|
  195. Returns the rectangle's area. This is equivalent to ``size.x * size.y``. See also :ref:`has_area<class_Rect2_method_has_area>`.
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_Rect2_method_get_center:
  199. .. rst-class:: classref-method
  200. :ref:`Vector2<class_Vector2>` **get_center** **(** **)** |const|
  201. Returns the center point of the rectangle. This is the same as ``position + (size / 2.0)``.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_Rect2_method_grow:
  205. .. rst-class:: classref-method
  206. :ref:`Rect2<class_Rect2>` **grow** **(** :ref:`float<class_float>` amount **)** |const|
  207. 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>`.
  208. .. tabs::
  209. .. code-tab:: gdscript
  210. var a = Rect2(4, 4, 8, 8).grow(4) # a is Rect2(0, 0, 16, 16)
  211. var b = Rect2(0, 0, 8, 4).grow(2) # b is Rect2(-2, -2, 12, 8)
  212. .. code-tab:: csharp
  213. var a = new Rect2(4, 4, 8, 8).Grow(4); // a is Rect2(0, 0, 16, 16)
  214. var b = new Rect2(0, 0, 8, 4).Grow(2); // b is Rect2(-2, -2, 12, 8)
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_Rect2_method_grow_individual:
  218. .. rst-class:: classref-method
  219. :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 **)** |const|
  220. 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>`.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_Rect2_method_grow_side:
  224. .. rst-class:: classref-method
  225. :ref:`Rect2<class_Rect2>` **grow_side** **(** :ref:`int<class_int>` side, :ref:`float<class_float>` amount **)** |const|
  226. 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>`.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_Rect2_method_has_area:
  230. .. rst-class:: classref-method
  231. :ref:`bool<class_bool>` **has_area** **(** **)** |const|
  232. Returns ``true`` if this rectangle has positive width and height. See also :ref:`get_area<class_Rect2_method_get_area>`.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_Rect2_method_has_point:
  236. .. rst-class:: classref-method
  237. :ref:`bool<class_bool>` **has_point** **(** :ref:`Vector2<class_Vector2>` point **)** |const|
  238. Returns ``true`` if the rectangle contains the given ``point``. By convention, points on the right and bottom edges are **not** included.
  239. \ **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.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_Rect2_method_intersection:
  243. .. rst-class:: classref-method
  244. :ref:`Rect2<class_Rect2>` **intersection** **(** :ref:`Rect2<class_Rect2>` b **)** |const|
  245. Returns the intersection between this rectangle and ``b``. If the rectangles do not intersect, returns an empty **Rect2**.
  246. .. tabs::
  247. .. code-tab:: gdscript
  248. var rect1 = Rect2(0, 0, 5, 10)
  249. var rect2 = Rect2(2, 0, 8, 4)
  250. var a = rect1.intersection(rect2) # a is Rect2(2, 0, 3, 4)
  251. .. code-tab:: csharp
  252. var rect1 = new Rect2(0, 0, 5, 10);
  253. var rect2 = new Rect2(2, 0, 8, 4);
  254. var a = rect1.Intersection(rect2); // a is Rect2(2, 0, 3, 4)
  255. \ **Note:** If you only need to know whether two rectangles are overlapping, use :ref:`intersects<class_Rect2_method_intersects>`, instead.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_Rect2_method_intersects:
  259. .. rst-class:: classref-method
  260. :ref:`bool<class_bool>` **intersects** **(** :ref:`Rect2<class_Rect2>` b, :ref:`bool<class_bool>` include_borders=false **)** |const|
  261. Returns ``true`` if this rectangle overlaps with the ``b`` rectangle. The edges of both rectangles are excluded, unless ``include_borders`` is ``true``.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_Rect2_method_is_equal_approx:
  265. .. rst-class:: classref-method
  266. :ref:`bool<class_bool>` **is_equal_approx** **(** :ref:`Rect2<class_Rect2>` rect **)** |const|
  267. 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>`.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_Rect2_method_is_finite:
  271. .. rst-class:: classref-method
  272. :ref:`bool<class_bool>` **is_finite** **(** **)** |const|
  273. 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>`.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_Rect2_method_merge:
  277. .. rst-class:: classref-method
  278. :ref:`Rect2<class_Rect2>` **merge** **(** :ref:`Rect2<class_Rect2>` b **)** |const|
  279. Returns a **Rect2** that encloses both this rectangle and ``b`` around the edges. See also :ref:`encloses<class_Rect2_method_encloses>`.
  280. .. rst-class:: classref-section-separator
  281. ----
  282. .. rst-class:: classref-descriptions-group
  283. Operator Descriptions
  284. ---------------------
  285. .. _class_Rect2_operator_neq_Rect2:
  286. .. rst-class:: classref-operator
  287. :ref:`bool<class_bool>` **operator !=** **(** :ref:`Rect2<class_Rect2>` right **)**
  288. Returns ``true`` if the :ref:`position<class_Rect2_property_position>` or :ref:`size<class_Rect2_property_size>` of both rectangles are not equal.
  289. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_Rect2_operator_mul_Transform2D:
  293. .. rst-class:: classref-operator
  294. :ref:`Rect2<class_Rect2>` **operator *** **(** :ref:`Transform2D<class_Transform2D>` right **)**
  295. 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).
  296. \ ``rect * transform`` is equivalent to ``transform.inverse() * rect``. See :ref:`Transform2D.inverse<class_Transform2D_method_inverse>`.
  297. 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>`.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_Rect2_operator_eq_Rect2:
  301. .. rst-class:: classref-operator
  302. :ref:`bool<class_bool>` **operator ==** **(** :ref:`Rect2<class_Rect2>` right **)**
  303. Returns ``true`` if both :ref:`position<class_Rect2_property_position>` and :ref:`size<class_Rect2_property_size>` of the rectangles are exactly equal, respectively.
  304. \ **Note:** Due to floating-point precision errors, consider using :ref:`is_equal_approx<class_Rect2_method_is_equal_approx>` instead, which is more reliable.
  305. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  306. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  307. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  308. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  309. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  310. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  311. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`