Rect2.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 documentation 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. <constructors>
  17. <constructor name="Rect2">
  18. <return type="Rect2" />
  19. <description>
  20. Constructs a default-initialized [Rect2] with default (zero) values of [member position] and [member size].
  21. </description>
  22. </constructor>
  23. <constructor name="Rect2">
  24. <return type="Rect2" />
  25. <argument index="0" name="from" type="Rect2" />
  26. <description>
  27. Constructs a [Rect2] as a copy of the given [Rect2].
  28. </description>
  29. </constructor>
  30. <constructor name="Rect2">
  31. <return type="Rect2" />
  32. <argument index="0" name="from" type="Rect2i" />
  33. <description>
  34. Constructs a [Rect2] from a [Rect2i].
  35. </description>
  36. </constructor>
  37. <constructor name="Rect2">
  38. <return type="Rect2" />
  39. <argument index="0" name="position" type="Vector2" />
  40. <argument index="1" name="size" type="Vector2" />
  41. <description>
  42. Constructs a [Rect2] by position and size.
  43. </description>
  44. </constructor>
  45. <constructor name="Rect2">
  46. <return type="Rect2" />
  47. <argument index="0" name="x" type="float" />
  48. <argument index="1" name="y" type="float" />
  49. <argument index="2" name="width" type="float" />
  50. <argument index="3" name="height" type="float" />
  51. <description>
  52. Constructs a [Rect2] by x, y, width, and height.
  53. </description>
  54. </constructor>
  55. </constructors>
  56. <methods>
  57. <method name="abs" qualifiers="const">
  58. <return type="Rect2" />
  59. <description>
  60. 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.
  61. </description>
  62. </method>
  63. <method name="encloses" qualifiers="const">
  64. <return type="bool" />
  65. <argument index="0" name="b" type="Rect2" />
  66. <description>
  67. Returns [code]true[/code] if this [Rect2] completely encloses another one.
  68. </description>
  69. </method>
  70. <method name="expand" qualifiers="const">
  71. <return type="Rect2" />
  72. <argument index="0" name="to" type="Vector2" />
  73. <description>
  74. Returns this [Rect2] expanded to include a given point.
  75. </description>
  76. </method>
  77. <method name="get_area" qualifiers="const">
  78. <return type="float" />
  79. <description>
  80. Returns the area of the [Rect2].
  81. </description>
  82. </method>
  83. <method name="get_center" qualifiers="const">
  84. <return type="Vector2" />
  85. <description>
  86. Returns the center of the [Rect2], which is equal to [member position] + ([member size] / 2).
  87. </description>
  88. </method>
  89. <method name="grow" qualifiers="const">
  90. <return type="Rect2" />
  91. <argument index="0" name="amount" type="float" />
  92. <description>
  93. Returns a copy of the [Rect2] grown by the specified [code]amount[/code] on all sides.
  94. </description>
  95. </method>
  96. <method name="grow_individual" qualifiers="const">
  97. <return type="Rect2" />
  98. <argument index="0" name="left" type="float" />
  99. <argument index="1" name="top" type="float" />
  100. <argument index="2" name="right" type="float" />
  101. <argument index="3" name="bottom" type="float" />
  102. <description>
  103. Returns a copy of the [Rect2] grown by the specified amount on each side individually.
  104. </description>
  105. </method>
  106. <method name="grow_side" qualifiers="const">
  107. <return type="Rect2" />
  108. <argument index="0" name="side" type="int" />
  109. <argument index="1" name="amount" type="float" />
  110. <description>
  111. Returns a copy of the [Rect2] grown by the specified [code]amount[/code] on the specified [enum Side].
  112. </description>
  113. </method>
  114. <method name="has_no_area" qualifiers="const">
  115. <return type="bool" />
  116. <description>
  117. Returns [code]true[/code] if the [Rect2] is flat or empty.
  118. </description>
  119. </method>
  120. <method name="has_point" qualifiers="const">
  121. <return type="bool" />
  122. <argument index="0" name="point" type="Vector2" />
  123. <description>
  124. Returns [code]true[/code] if the [Rect2] contains a point.
  125. </description>
  126. </method>
  127. <method name="intersection" qualifiers="const">
  128. <return type="Rect2" />
  129. <argument index="0" name="b" type="Rect2" />
  130. <description>
  131. Returns the intersection of this [Rect2] and [code]b[/code].
  132. If the rectangles do not intersect, an empty [Rect2] is returned.
  133. </description>
  134. </method>
  135. <method name="intersects" qualifiers="const">
  136. <return type="bool" />
  137. <argument index="0" name="b" type="Rect2" />
  138. <argument index="1" name="include_borders" type="bool" default="false" />
  139. <description>
  140. Returns [code]true[/code] if the [Rect2] overlaps with [code]b[/code] (i.e. they have at least one point in common).
  141. If [code]include_borders[/code] is [code]true[/code], they will also be considered overlapping if their borders touch, even without intersection.
  142. </description>
  143. </method>
  144. <method name="is_equal_approx" qualifiers="const">
  145. <return type="bool" />
  146. <argument index="0" name="rect" type="Rect2" />
  147. <description>
  148. Returns [code]true[/code] if this [Rect2] and [code]rect[/code] are approximately equal, by calling [code]is_equal_approx[/code] on each component.
  149. </description>
  150. </method>
  151. <method name="merge" qualifiers="const">
  152. <return type="Rect2" />
  153. <argument index="0" name="b" type="Rect2" />
  154. <description>
  155. Returns a larger [Rect2] that contains this [Rect2] and [code]b[/code].
  156. </description>
  157. </method>
  158. </methods>
  159. <members>
  160. <member name="end" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
  161. Ending corner. This is calculated as [code]position + size[/code]. Setting this value will change the size.
  162. </member>
  163. <member name="position" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
  164. Beginning corner. Typically has values lower than [member end].
  165. </member>
  166. <member name="size" type="Vector2" setter="" getter="" default="Vector2(0, 0)">
  167. Size from [member position] to [member end]. Typically, all components are positive.
  168. If the size is negative, you can use [method abs] to fix it.
  169. </member>
  170. </members>
  171. <operators>
  172. <operator name="operator !=">
  173. <return type="bool" />
  174. <description>
  175. </description>
  176. </operator>
  177. <operator name="operator !=">
  178. <return type="bool" />
  179. <argument index="0" name="right" type="Rect2" />
  180. <description>
  181. </description>
  182. </operator>
  183. <operator name="operator *">
  184. <return type="Rect2" />
  185. <argument index="0" name="right" type="Transform2D" />
  186. <description>
  187. </description>
  188. </operator>
  189. <operator name="operator ==">
  190. <return type="bool" />
  191. <description>
  192. </description>
  193. </operator>
  194. <operator name="operator ==">
  195. <return type="bool" />
  196. <argument index="0" name="right" type="Rect2" />
  197. <description>
  198. </description>
  199. </operator>
  200. </operators>
  201. </class>