Rect2.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Rect2" version="4.0">
  3. <brief_description>
  4. 2D axis-aligned bounding box using floating point coordinates.
  5. </brief_description>
  6. <description>
  7. [Rect2] consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
  8. It uses floating-point coordinates. If you need integer coordinates, use [Rect2i] instead.
  9. The 3D counterpart to [Rect2] is [AABB].
  10. </description>
  11. <tutorials>
  12. <link title="Math tutorial index">https://docs.godotengine.org/en/latest/tutorials/math/index.html</link>
  13. <link title="Vector math">https://docs.godotengine.org/en/latest/tutorials/math/vector_math.html</link>
  14. <link title="Advanced vector math">https://docs.godotengine.org/en/latest/tutorials/math/vectors_advanced.html</link>
  15. </tutorials>
  16. <methods>
  17. <method name="Rect2" qualifiers="constructor">
  18. <return type="Rect2">
  19. </return>
  20. <description>
  21. Constructs a default-initialized [Rect2] with default (zero) values of [member position] and [member size].
  22. </description>
  23. </method>
  24. <method name="Rect2" qualifiers="constructor">
  25. <return type="Rect2">
  26. </return>
  27. <argument index="0" name="from" type="Rect2">
  28. </argument>
  29. <description>
  30. Constructs a [Rect2] as a copy of the given [Rect2].
  31. </description>
  32. </method>
  33. <method name="Rect2" qualifiers="constructor">
  34. <return type="Rect2">
  35. </return>
  36. <argument index="0" name="from" type="Rect2i">
  37. </argument>
  38. <description>
  39. Constructs a [Rect2] from a [Rect2i].
  40. </description>
  41. </method>
  42. <method name="Rect2" qualifiers="constructor">
  43. <return type="Rect2">
  44. </return>
  45. <argument index="0" name="position" type="Vector2">
  46. </argument>
  47. <argument index="1" name="size" type="Vector2">
  48. </argument>
  49. <description>
  50. Constructs a [Rect2] by position and size.
  51. </description>
  52. </method>
  53. <method name="Rect2" qualifiers="constructor">
  54. <return type="Rect2">
  55. </return>
  56. <argument index="0" name="x" type="float">
  57. </argument>
  58. <argument index="1" name="y" type="float">
  59. </argument>
  60. <argument index="2" name="width" type="float">
  61. </argument>
  62. <argument index="3" name="height" type="float">
  63. </argument>
  64. <description>
  65. Constructs a [Rect2] by x, y, width, and height.
  66. </description>
  67. </method>
  68. <method name="abs">
  69. <return type="Rect2">
  70. </return>
  71. <description>
  72. Returns a [Rect2] with equivalent position and area, modified so that the top-left corner is the origin and [code]width[/code] and [code]height[/code] are positive.
  73. </description>
  74. </method>
  75. <method name="intersection">
  76. <return type="Rect2">
  77. </return>
  78. <argument index="0" name="b" type="Rect2">
  79. </argument>
  80. <description>
  81. Returns the intersection of this [Rect2] and b.
  82. </description>
  83. </method>
  84. <method name="encloses">
  85. <return type="bool">
  86. </return>
  87. <argument index="0" name="b" type="Rect2">
  88. </argument>
  89. <description>
  90. Returns [code]true[/code] if this [Rect2] completely encloses another one.
  91. </description>
  92. </method>
  93. <method name="expand">
  94. <return type="Rect2">
  95. </return>
  96. <argument index="0" name="to" type="Vector2">
  97. </argument>
  98. <description>
  99. Returns this [Rect2] expanded to include a given point.
  100. </description>
  101. </method>
  102. <method name="get_area">
  103. <return type="float">
  104. </return>
  105. <description>
  106. Returns the area of the [Rect2].
  107. </description>
  108. </method>
  109. <method name="grow">
  110. <return type="Rect2">
  111. </return>
  112. <argument index="0" name="by" type="float">
  113. </argument>
  114. <description>
  115. Returns a copy of the [Rect2] grown a given amount of units towards all the sides.
  116. </description>
  117. </method>
  118. <method name="grow_individual">
  119. <return type="Rect2">
  120. </return>
  121. <argument index="0" name="left" type="float">
  122. </argument>
  123. <argument index="1" name="top" type="float">
  124. </argument>
  125. <argument index="2" name="right" type="float">
  126. </argument>
  127. <argument index="3" name="bottom" type="float">
  128. </argument>
  129. <description>
  130. Returns a copy of the [Rect2] grown a given amount of units towards each direction individually.
  131. </description>
  132. </method>
  133. <method name="grow_margin">
  134. <return type="Rect2">
  135. </return>
  136. <argument index="0" name="margin" type="int">
  137. </argument>
  138. <argument index="1" name="by" type="float">
  139. </argument>
  140. <description>
  141. Returns a copy of the [Rect2] grown a given amount of units towards the [enum Margin] direction.
  142. </description>
  143. </method>
  144. <method name="has_no_area">
  145. <return type="bool">
  146. </return>
  147. <description>
  148. Returns [code]true[/code] if the [Rect2] is flat or empty.
  149. </description>
  150. </method>
  151. <method name="has_point">
  152. <return type="bool">
  153. </return>
  154. <argument index="0" name="point" type="Vector2">
  155. </argument>
  156. <description>
  157. Returns [code]true[/code] if the [Rect2] contains a point.
  158. </description>
  159. </method>
  160. <method name="intersects">
  161. <return type="bool">
  162. </return>
  163. <argument index="0" name="b" type="Rect2">
  164. </argument>
  165. <argument index="1" name="include_borders" type="bool" default="false">
  166. </argument>
  167. <description>
  168. Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common).
  169. If [code]include_borders[/code] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection.
  170. </description>
  171. </method>
  172. <method name="is_equal_approx">
  173. <return type="bool">
  174. </return>
  175. <argument index="0" name="rect" type="Rect2">
  176. </argument>
  177. <description>
  178. Returns [code]true[/code] if this [Rect2] and [code]rect[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component.
  179. </description>
  180. </method>
  181. <method name="merge">
  182. <return type="Rect2">
  183. </return>
  184. <argument index="0" name="b" type="Rect2">
  185. </argument>
  186. <description>
  187. Returns a larger [Rect2] that contains this [Rect2] and [code]b[/code].
  188. </description>
  189. </method>
  190. <method name="operator !=" qualifiers="operator">
  191. <return type="bool">
  192. </return>
  193. <argument index="0" name="right" type="Rect2">
  194. </argument>
  195. <description>
  196. </description>
  197. </method>
  198. <method name="operator *" qualifiers="operator">
  199. <return type="Rect2">
  200. </return>
  201. <argument index="0" name="right" type="Transform2D">
  202. </argument>
  203. <description>
  204. </description>
  205. </method>
  206. <method name="operator ==" qualifiers="operator">
  207. <return type="bool">
  208. </return>
  209. <argument index="0" name="right" type="Rect2">
  210. </argument>
  211. <description>
  212. </description>
  213. </method>
  214. </methods>
  215. <members>
  216. <member name="end" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
  217. Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
  218. </member>
  219. <member name="position" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
  220. Beginning corner. Typically has values lower than [member end].
  221. </member>
  222. <member name="size" type="Vector2" setter="" getter="" default="Vector2( 0, 0 )">
  223. Size from [member position] to [member end]. Typically all components are positive.
  224. If the size is negative, you can use [method abs] to fix it.
  225. </member>
  226. </members>
  227. <constants>
  228. </constants>
  229. </class>