class_gradient.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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/Gradient.xml.
  6. .. _class_Gradient:
  7. Gradient
  8. ========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A color transition.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This resource describes a color transition by defining a set of colored points and how to interpolate between them.
  15. See also :ref:`Curve<class_Curve>` which supports more complex easing methods, but does not support colors.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +-----------------------------------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
  22. | :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`colors<class_Gradient_property_colors>` | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` |
  23. +-----------------------------------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
  24. | :ref:`ColorSpace<enum_Gradient_ColorSpace>` | :ref:`interpolation_color_space<class_Gradient_property_interpolation_color_space>` | ``0`` |
  25. +-----------------------------------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
  26. | :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` | :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` | ``0`` |
  27. +-----------------------------------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
  28. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`offsets<class_Gradient_property_offsets>` | ``PackedFloat32Array(0, 1)`` |
  29. +-----------------------------------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  36. | |void| | :ref:`add_point<class_Gradient_method_add_point>`\ (\ offset\: :ref:`float<class_float>`, color\: :ref:`Color<class_Color>`\ ) |
  37. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`Color<class_Color>` | :ref:`get_color<class_Gradient_method_get_color>`\ (\ point\: :ref:`int<class_int>`\ ) |
  39. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`float<class_float>` | :ref:`get_offset<class_Gradient_method_get_offset>`\ (\ point\: :ref:`int<class_int>`\ ) |
  41. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`get_point_count<class_Gradient_method_get_point_count>`\ (\ ) |const| |
  43. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`remove_point<class_Gradient_method_remove_point>`\ (\ point\: :ref:`int<class_int>`\ ) |
  45. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  46. | |void| | :ref:`reverse<class_Gradient_method_reverse>`\ (\ ) |
  47. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`Color<class_Color>` | :ref:`sample<class_Gradient_method_sample>`\ (\ offset\: :ref:`float<class_float>`\ ) |
  49. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`set_color<class_Gradient_method_set_color>`\ (\ point\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) |
  51. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  52. | |void| | :ref:`set_offset<class_Gradient_method_set_offset>`\ (\ point\: :ref:`int<class_int>`, offset\: :ref:`float<class_float>`\ ) |
  53. +---------------------------+--------------------------------------------------------------------------------------------------------------------------------+
  54. .. rst-class:: classref-section-separator
  55. ----
  56. .. rst-class:: classref-descriptions-group
  57. Enumerations
  58. ------------
  59. .. _enum_Gradient_InterpolationMode:
  60. .. rst-class:: classref-enumeration
  61. enum **InterpolationMode**: :ref:`🔗<enum_Gradient_InterpolationMode>`
  62. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_LINEAR:
  63. .. rst-class:: classref-enumeration-constant
  64. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_LINEAR** = ``0``
  65. Linear interpolation.
  66. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT:
  67. .. rst-class:: classref-enumeration-constant
  68. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_CONSTANT** = ``1``
  69. Constant interpolation, color changes abruptly at each point and stays uniform between. This might cause visible aliasing when used for a gradient texture in some cases.
  70. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CUBIC:
  71. .. rst-class:: classref-enumeration-constant
  72. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_CUBIC** = ``2``
  73. Cubic interpolation.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _enum_Gradient_ColorSpace:
  77. .. rst-class:: classref-enumeration
  78. enum **ColorSpace**: :ref:`🔗<enum_Gradient_ColorSpace>`
  79. .. _class_Gradient_constant_GRADIENT_COLOR_SPACE_SRGB:
  80. .. rst-class:: classref-enumeration-constant
  81. :ref:`ColorSpace<enum_Gradient_ColorSpace>` **GRADIENT_COLOR_SPACE_SRGB** = ``0``
  82. sRGB color space.
  83. .. _class_Gradient_constant_GRADIENT_COLOR_SPACE_LINEAR_SRGB:
  84. .. rst-class:: classref-enumeration-constant
  85. :ref:`ColorSpace<enum_Gradient_ColorSpace>` **GRADIENT_COLOR_SPACE_LINEAR_SRGB** = ``1``
  86. Linear sRGB color space.
  87. .. _class_Gradient_constant_GRADIENT_COLOR_SPACE_OKLAB:
  88. .. rst-class:: classref-enumeration-constant
  89. :ref:`ColorSpace<enum_Gradient_ColorSpace>` **GRADIENT_COLOR_SPACE_OKLAB** = ``2``
  90. `Oklab <https://bottosson.github.io/posts/oklab/>`__ color space. This color space provides a smooth and uniform-looking transition between colors.
  91. .. rst-class:: classref-section-separator
  92. ----
  93. .. rst-class:: classref-descriptions-group
  94. Property Descriptions
  95. ---------------------
  96. .. _class_Gradient_property_colors:
  97. .. rst-class:: classref-property
  98. :ref:`PackedColorArray<class_PackedColorArray>` **colors** = ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` :ref:`🔗<class_Gradient_property_colors>`
  99. .. rst-class:: classref-property-setget
  100. - |void| **set_colors**\ (\ value\: :ref:`PackedColorArray<class_PackedColorArray>`\ )
  101. - :ref:`PackedColorArray<class_PackedColorArray>` **get_colors**\ (\ )
  102. Gradient's colors as a :ref:`PackedColorArray<class_PackedColorArray>`.
  103. \ **Note:** Setting this property updates all colors at once. To update any color individually use :ref:`set_color<class_Gradient_method_set_color>`.
  104. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedColorArray<class_PackedColorArray>` for more details.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_Gradient_property_interpolation_color_space:
  108. .. rst-class:: classref-property
  109. :ref:`ColorSpace<enum_Gradient_ColorSpace>` **interpolation_color_space** = ``0`` :ref:`🔗<class_Gradient_property_interpolation_color_space>`
  110. .. rst-class:: classref-property-setget
  111. - |void| **set_interpolation_color_space**\ (\ value\: :ref:`ColorSpace<enum_Gradient_ColorSpace>`\ )
  112. - :ref:`ColorSpace<enum_Gradient_ColorSpace>` **get_interpolation_color_space**\ (\ )
  113. The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always be in sRGB space. See :ref:`ColorSpace<enum_Gradient_ColorSpace>` for available modes.
  114. \ **Note:** This setting has no effect when :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` is set to :ref:`GRADIENT_INTERPOLATE_CONSTANT<class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT>`.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_Gradient_property_interpolation_mode:
  118. .. rst-class:: classref-property
  119. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **interpolation_mode** = ``0`` :ref:`🔗<class_Gradient_property_interpolation_mode>`
  120. .. rst-class:: classref-property-setget
  121. - |void| **set_interpolation_mode**\ (\ value\: :ref:`InterpolationMode<enum_Gradient_InterpolationMode>`\ )
  122. - :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **get_interpolation_mode**\ (\ )
  123. The algorithm used to interpolate between points of the gradient. See :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` for available modes.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_Gradient_property_offsets:
  127. .. rst-class:: classref-property
  128. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **offsets** = ``PackedFloat32Array(0, 1)`` :ref:`🔗<class_Gradient_property_offsets>`
  129. .. rst-class:: classref-property-setget
  130. - |void| **set_offsets**\ (\ value\: :ref:`PackedFloat32Array<class_PackedFloat32Array>`\ )
  131. - :ref:`PackedFloat32Array<class_PackedFloat32Array>` **get_offsets**\ (\ )
  132. Gradient's offsets as a :ref:`PackedFloat32Array<class_PackedFloat32Array>`.
  133. \ **Note:** Setting this property updates all offsets at once. To update any offset individually use :ref:`set_offset<class_Gradient_method_set_offset>`.
  134. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See :ref:`PackedFloat32Array<class_PackedFloat32Array>` for more details.
  135. .. rst-class:: classref-section-separator
  136. ----
  137. .. rst-class:: classref-descriptions-group
  138. Method Descriptions
  139. -------------------
  140. .. _class_Gradient_method_add_point:
  141. .. rst-class:: classref-method
  142. |void| **add_point**\ (\ offset\: :ref:`float<class_float>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Gradient_method_add_point>`
  143. Adds the specified color to the gradient, with the specified offset.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_Gradient_method_get_color:
  147. .. rst-class:: classref-method
  148. :ref:`Color<class_Color>` **get_color**\ (\ point\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Gradient_method_get_color>`
  149. Returns the color of the gradient color at index ``point``.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_Gradient_method_get_offset:
  153. .. rst-class:: classref-method
  154. :ref:`float<class_float>` **get_offset**\ (\ point\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Gradient_method_get_offset>`
  155. Returns the offset of the gradient color at index ``point``.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_Gradient_method_get_point_count:
  159. .. rst-class:: classref-method
  160. :ref:`int<class_int>` **get_point_count**\ (\ ) |const| :ref:`🔗<class_Gradient_method_get_point_count>`
  161. Returns the number of colors in the gradient.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_Gradient_method_remove_point:
  165. .. rst-class:: classref-method
  166. |void| **remove_point**\ (\ point\: :ref:`int<class_int>`\ ) :ref:`🔗<class_Gradient_method_remove_point>`
  167. Removes the color at index ``point``.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_Gradient_method_reverse:
  171. .. rst-class:: classref-method
  172. |void| **reverse**\ (\ ) :ref:`🔗<class_Gradient_method_reverse>`
  173. Reverses/mirrors the gradient.
  174. \ **Note:** This method mirrors all points around the middle of the gradient, which may produce unexpected results when :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` is set to :ref:`GRADIENT_INTERPOLATE_CONSTANT<class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT>`.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_Gradient_method_sample:
  178. .. rst-class:: classref-method
  179. :ref:`Color<class_Color>` **sample**\ (\ offset\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Gradient_method_sample>`
  180. Returns the interpolated color specified by ``offset``.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_Gradient_method_set_color:
  184. .. rst-class:: classref-method
  185. |void| **set_color**\ (\ point\: :ref:`int<class_int>`, color\: :ref:`Color<class_Color>`\ ) :ref:`🔗<class_Gradient_method_set_color>`
  186. Sets the color of the gradient color at index ``point``.
  187. .. rst-class:: classref-item-separator
  188. ----
  189. .. _class_Gradient_method_set_offset:
  190. .. rst-class:: classref-method
  191. |void| **set_offset**\ (\ point\: :ref:`int<class_int>`, offset\: :ref:`float<class_float>`\ ) :ref:`🔗<class_Gradient_method_set_offset>`
  192. Sets the offset for the gradient color at index ``point``.
  193. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  194. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  195. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  196. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  197. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  198. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  199. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  200. .. |void| replace:: :abbr:`void (No return value.)`