class_rect2.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Rect2.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Rect2:
  6. Rect2
  7. =====
  8. **Category:** Built-In Types
  9. Brief Description
  10. -----------------
  11. 2D axis-aligned bounding box.
  12. Properties
  13. ----------
  14. +-------------------------------+------------------------------------------------+-----------------+
  15. | :ref:`Vector2<class_Vector2>` | :ref:`end<class_Rect2_property_end>` | Vector2( 0, 0 ) |
  16. +-------------------------------+------------------------------------------------+-----------------+
  17. | :ref:`Vector2<class_Vector2>` | :ref:`position<class_Rect2_property_position>` | Vector2( 0, 0 ) |
  18. +-------------------------------+------------------------------------------------+-----------------+
  19. | :ref:`Vector2<class_Vector2>` | :ref:`size<class_Rect2_property_size>` | Vector2( 0, 0 ) |
  20. +-------------------------------+------------------------------------------------+-----------------+
  21. Methods
  22. -------
  23. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_method_Rect2>` **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)** |
  25. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`Rect2<class_Rect2>` | :ref:`Rect2<class_Rect2_method_Rect2>` **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y, :ref:`float<class_float>` width, :ref:`float<class_float>` height **)** |
  27. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Rect2<class_Rect2>` | :ref:`abs<class_Rect2_method_abs>` **(** **)** |
  29. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Rect2<class_Rect2>` | :ref:`clip<class_Rect2_method_clip>` **(** :ref:`Rect2<class_Rect2>` b **)** |
  31. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`encloses<class_Rect2_method_encloses>` **(** :ref:`Rect2<class_Rect2>` b **)** |
  33. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Rect2<class_Rect2>` | :ref:`expand<class_Rect2_method_expand>` **(** :ref:`Vector2<class_Vector2>` to **)** |
  35. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`float<class_float>` | :ref:`get_area<class_Rect2_method_get_area>` **(** **)** |
  37. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Rect2<class_Rect2>` | :ref:`grow<class_Rect2_method_grow>` **(** :ref:`float<class_float>` by **)** |
  39. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :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 **)** |
  41. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Rect2<class_Rect2>` | :ref:`grow_margin<class_Rect2_method_grow_margin>` **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` by **)** |
  43. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`has_no_area<class_Rect2_method_has_no_area>` **(** **)** |
  45. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | :ref:`has_point<class_Rect2_method_has_point>` **(** :ref:`Vector2<class_Vector2>` point **)** |
  47. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`intersects<class_Rect2_method_intersects>` **(** :ref:`Rect2<class_Rect2>` b **)** |
  49. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Rect2<class_Rect2>` | :ref:`merge<class_Rect2_method_merge>` **(** :ref:`Rect2<class_Rect2>` b **)** |
  51. +---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. Description
  53. -----------
  54. Rect2 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
  55. Tutorials
  56. ---------
  57. - :doc:`../tutorials/math/index`
  58. Property Descriptions
  59. ---------------------
  60. .. _class_Rect2_property_end:
  61. - :ref:`Vector2<class_Vector2>` **end**
  62. +-----------+-----------------+
  63. | *Default* | Vector2( 0, 0 ) |
  64. +-----------+-----------------+
  65. Ending corner.
  66. .. _class_Rect2_property_position:
  67. - :ref:`Vector2<class_Vector2>` **position**
  68. +-----------+-----------------+
  69. | *Default* | Vector2( 0, 0 ) |
  70. +-----------+-----------------+
  71. Position (starting corner).
  72. .. _class_Rect2_property_size:
  73. - :ref:`Vector2<class_Vector2>` **size**
  74. +-----------+-----------------+
  75. | *Default* | Vector2( 0, 0 ) |
  76. +-----------+-----------------+
  77. Size from position to end.
  78. Method Descriptions
  79. -------------------
  80. .. _class_Rect2_method_Rect2:
  81. - :ref:`Rect2<class_Rect2>` **Rect2** **(** :ref:`Vector2<class_Vector2>` position, :ref:`Vector2<class_Vector2>` size **)**
  82. Constructs a ``Rect2`` by position and size.
  83. - :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 **)**
  84. Constructs a ``Rect2`` by x, y, width, and height.
  85. .. _class_Rect2_method_abs:
  86. - :ref:`Rect2<class_Rect2>` **abs** **(** **)**
  87. Returns a ``Rect2`` with equivalent position and area, modified so that the top-left corner is the origin and ``width`` and ``height`` are positive.
  88. .. _class_Rect2_method_clip:
  89. - :ref:`Rect2<class_Rect2>` **clip** **(** :ref:`Rect2<class_Rect2>` b **)**
  90. Returns the intersection of this ``Rect2`` and b.
  91. .. _class_Rect2_method_encloses:
  92. - :ref:`bool<class_bool>` **encloses** **(** :ref:`Rect2<class_Rect2>` b **)**
  93. Returns ``true`` if this ``Rect2`` completely encloses another one.
  94. .. _class_Rect2_method_expand:
  95. - :ref:`Rect2<class_Rect2>` **expand** **(** :ref:`Vector2<class_Vector2>` to **)**
  96. Returns this ``Rect2`` expanded to include a given point.
  97. .. _class_Rect2_method_get_area:
  98. - :ref:`float<class_float>` **get_area** **(** **)**
  99. Returns the area of the ``Rect2``.
  100. .. _class_Rect2_method_grow:
  101. - :ref:`Rect2<class_Rect2>` **grow** **(** :ref:`float<class_float>` by **)**
  102. Returns a copy of the ``Rect2`` grown a given amount of units towards all the sides.
  103. .. _class_Rect2_method_grow_individual:
  104. - :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 **)**
  105. Returns a copy of the ``Rect2`` grown a given amount of units towards each direction individually.
  106. .. _class_Rect2_method_grow_margin:
  107. - :ref:`Rect2<class_Rect2>` **grow_margin** **(** :ref:`int<class_int>` margin, :ref:`float<class_float>` by **)**
  108. Returns a copy of the ``Rect2`` grown a given amount of units towards the :ref:`Margin<enum_@GlobalScope_Margin>` direction.
  109. .. _class_Rect2_method_has_no_area:
  110. - :ref:`bool<class_bool>` **has_no_area** **(** **)**
  111. Returns ``true`` if the ``Rect2`` is flat or empty.
  112. .. _class_Rect2_method_has_point:
  113. - :ref:`bool<class_bool>` **has_point** **(** :ref:`Vector2<class_Vector2>` point **)**
  114. Returns ``true`` if the ``Rect2`` contains a point.
  115. .. _class_Rect2_method_intersects:
  116. - :ref:`bool<class_bool>` **intersects** **(** :ref:`Rect2<class_Rect2>` b **)**
  117. Returns ``true`` if the ``Rect2`` overlaps with another.
  118. .. _class_Rect2_method_merge:
  119. - :ref:`Rect2<class_Rect2>` **merge** **(** :ref:`Rect2<class_Rect2>` b **)**
  120. Returns a larger Rect2 that contains this Rect2 and ``b``.