class_poolcolorarray.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/PoolColorArray.xml.
  6. .. _class_PoolColorArray:
  7. PoolColorArray
  8. ==============
  9. A pooled array of :ref:`Color<class_Color>`\ s.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold :ref:`Color<class_Color>`. Optimized for memory usage, does not fragment the memory.
  14. \ **Note:** This type is passed by value and not by reference. This means that when *mutating* a class property of type **PoolColorArray** or mutating a **PoolColorArray** within an :ref:`Array<class_Array>` or :ref:`Dictionary<class_Dictionary>`, changes will be lost:
  15. ::
  16. var array = [PoolColorArray()]
  17. array[0].push_back(Color(0.1, 0.2, 0.3, 0.4))
  18. print(array) # [[]] (empty PoolColorArray within an Array)
  19. Instead, the entire **PoolColorArray** property must be *reassigned* with ``=`` for it to be changed:
  20. ::
  21. var array = [PoolColorArray()]
  22. var pool_array = array[0]
  23. pool_array.push_back(Color(0.1, 0.2, 0.3, 0.4))
  24. array[0] = pool_array
  25. print(array) # [[(0.1, 0.2, 0.3, 0.4)]] (PoolColorArray with 1 element inside an Array)
  26. .. rst-class:: classref-reftable-group
  27. Methods
  28. -------
  29. .. table::
  30. :widths: auto
  31. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`PoolColorArray<class_PoolColorArray>` | :ref:`PoolColorArray<class_PoolColorArray_method_PoolColorArray>` **(** :ref:`Array<class_Array>` from **)** |
  33. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`append<class_PoolColorArray_method_append>` **(** :ref:`Color<class_Color>` color **)** |
  35. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`append_array<class_PoolColorArray_method_append_array>` **(** :ref:`PoolColorArray<class_PoolColorArray>` array **)** |
  37. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`clear<class_PoolColorArray_method_clear>` **(** **)** |
  39. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`count<class_PoolColorArray_method_count>` **(** :ref:`Color<class_Color>` value **)** |
  41. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`empty<class_PoolColorArray_method_empty>` **(** **)** |
  43. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`fill<class_PoolColorArray_method_fill>` **(** :ref:`Color<class_Color>` color **)** |
  45. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`find<class_PoolColorArray_method_find>` **(** :ref:`Color<class_Color>` value, :ref:`int<class_int>` from=0 **)** |
  47. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`has<class_PoolColorArray_method_has>` **(** :ref:`Color<class_Color>` value **)** |
  49. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`insert<class_PoolColorArray_method_insert>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` color **)** |
  51. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`invert<class_PoolColorArray_method_invert>` **(** **)** |
  53. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`push_back<class_PoolColorArray_method_push_back>` **(** :ref:`Color<class_Color>` color **)** |
  55. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`remove<class_PoolColorArray_method_remove>` **(** :ref:`int<class_int>` idx **)** |
  57. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`resize<class_PoolColorArray_method_resize>` **(** :ref:`int<class_int>` idx **)** |
  59. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`rfind<class_PoolColorArray_method_rfind>` **(** :ref:`Color<class_Color>` value, :ref:`int<class_int>` from=-1 **)** |
  61. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set<class_PoolColorArray_method_set>` **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` color **)** |
  63. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`size<class_PoolColorArray_method_size>` **(** **)** |
  65. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`sort<class_PoolColorArray_method_sort>` **(** **)** |
  67. +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+
  68. .. rst-class:: classref-section-separator
  69. ----
  70. .. rst-class:: classref-descriptions-group
  71. Method Descriptions
  72. -------------------
  73. .. _class_PoolColorArray_method_PoolColorArray:
  74. .. rst-class:: classref-method
  75. :ref:`PoolColorArray<class_PoolColorArray>` **PoolColorArray** **(** :ref:`Array<class_Array>` from **)**
  76. Constructs a new **PoolColorArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  77. .. rst-class:: classref-item-separator
  78. ----
  79. .. _class_PoolColorArray_method_append:
  80. .. rst-class:: classref-method
  81. void **append** **(** :ref:`Color<class_Color>` color **)**
  82. Appends an element at the end of the array (alias of :ref:`push_back<class_PoolColorArray_method_push_back>`).
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_PoolColorArray_method_append_array:
  86. .. rst-class:: classref-method
  87. void **append_array** **(** :ref:`PoolColorArray<class_PoolColorArray>` array **)**
  88. Appends a **PoolColorArray** at the end of this array.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_PoolColorArray_method_clear:
  92. .. rst-class:: classref-method
  93. void **clear** **(** **)**
  94. Clears the array. This is equivalent to using :ref:`resize<class_PoolColorArray_method_resize>` with a size of ``0``.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_PoolColorArray_method_count:
  98. .. rst-class:: classref-method
  99. :ref:`int<class_int>` **count** **(** :ref:`Color<class_Color>` value **)**
  100. Returns the number of times an element is in the array.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_PoolColorArray_method_empty:
  104. .. rst-class:: classref-method
  105. :ref:`bool<class_bool>` **empty** **(** **)**
  106. Returns ``true`` if the array is empty.
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _class_PoolColorArray_method_fill:
  110. .. rst-class:: classref-method
  111. void **fill** **(** :ref:`Color<class_Color>` color **)**
  112. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PoolColorArray_method_resize>` to create an array with a given size and initialized elements.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_PoolColorArray_method_find:
  116. .. rst-class:: classref-method
  117. :ref:`int<class_int>` **find** **(** :ref:`Color<class_Color>` value, :ref:`int<class_int>` from=0 **)**
  118. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed. Returns ``-1`` if ``from`` is out of bounds.
  119. .. rst-class:: classref-item-separator
  120. ----
  121. .. _class_PoolColorArray_method_has:
  122. .. rst-class:: classref-method
  123. :ref:`bool<class_bool>` **has** **(** :ref:`Color<class_Color>` value **)**
  124. Returns ``true`` if the array contains the given value.
  125. \ **Note:** This is equivalent to using the ``in`` operator.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _class_PoolColorArray_method_insert:
  129. .. rst-class:: classref-method
  130. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` color **)**
  131. Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_PoolColorArray_method_invert:
  135. .. rst-class:: classref-method
  136. void **invert** **(** **)**
  137. Reverses the order of the elements in the array.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_PoolColorArray_method_push_back:
  141. .. rst-class:: classref-method
  142. void **push_back** **(** :ref:`Color<class_Color>` color **)**
  143. Appends a value to the array.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_PoolColorArray_method_remove:
  147. .. rst-class:: classref-method
  148. void **remove** **(** :ref:`int<class_int>` idx **)**
  149. Removes an element from the array by index.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_PoolColorArray_method_resize:
  153. .. rst-class:: classref-method
  154. void **resize** **(** :ref:`int<class_int>` idx **)**
  155. Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_PoolColorArray_method_rfind:
  159. .. rst-class:: classref-method
  160. :ref:`int<class_int>` **rfind** **(** :ref:`Color<class_Color>` value, :ref:`int<class_int>` from=-1 **)**
  161. Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array. If the adjusted start index is out of bounds, this method searches from the end of the array.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_PoolColorArray_method_set:
  165. .. rst-class:: classref-method
  166. void **set** **(** :ref:`int<class_int>` idx, :ref:`Color<class_Color>` color **)**
  167. Changes the :ref:`Color<class_Color>` at the given index.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_PoolColorArray_method_size:
  171. .. rst-class:: classref-method
  172. :ref:`int<class_int>` **size** **(** **)**
  173. Returns the number of elements in the array.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_PoolColorArray_method_sort:
  177. .. rst-class:: classref-method
  178. void **sort** **(** **)**
  179. Sorts the elements of the array in ascending order.
  180. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  181. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  182. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  183. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`