class_gradient.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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/Gradient.xml.
  6. .. _class_Gradient:
  7. Gradient
  8. ========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. A color interpolator resource which can be used to generate colors between user-defined color points.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Given a set of colors, this resource will interpolate them in order. This means that if you have color 1, color 2 and color 3, the gradient will interpolate from color 1 to color 2 and from color 2 to color 3. The gradient will initially have 2 colors (black and white), one (black) at gradient lower offset 0 and the other (white) at the gradient higher offset 1.
  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:`PoolColorArray<class_PoolColorArray>` | :ref:`colors<class_Gradient_property_colors>` | ``PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )`` |
  23. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  24. | :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` | :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` | ``0`` |
  25. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  26. | :ref:`PoolRealArray<class_PoolRealArray>` | :ref:`offsets<class_Gradient_property_offsets>` | ``PoolRealArray( 0, 1 )`` |
  27. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  28. .. rst-class:: classref-reftable-group
  29. Methods
  30. -------
  31. .. table::
  32. :widths: auto
  33. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`add_point<class_Gradient_method_add_point>` **(** :ref:`float<class_float>` offset, :ref:`Color<class_Color>` color **)** |
  35. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`Color<class_Color>` | :ref:`get_color<class_Gradient_method_get_color>` **(** :ref:`int<class_int>` point **)** |
  37. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`get_offset<class_Gradient_method_get_offset>` **(** :ref:`int<class_int>` point **)** |
  39. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`get_point_count<class_Gradient_method_get_point_count>` **(** **)** |const| |
  41. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Color<class_Color>` | :ref:`interpolate<class_Gradient_method_interpolate>` **(** :ref:`float<class_float>` offset **)** |
  43. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`remove_point<class_Gradient_method_remove_point>` **(** :ref:`int<class_int>` point **)** |
  45. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`set_color<class_Gradient_method_set_color>` **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)** |
  47. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`set_offset<class_Gradient_method_set_offset>` **(** :ref:`int<class_int>` point, :ref:`float<class_float>` offset **)** |
  49. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  50. .. rst-class:: classref-section-separator
  51. ----
  52. .. rst-class:: classref-descriptions-group
  53. Enumerations
  54. ------------
  55. .. _enum_Gradient_InterpolationMode:
  56. .. rst-class:: classref-enumeration
  57. enum **InterpolationMode**:
  58. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_LINEAR:
  59. .. rst-class:: classref-enumeration-constant
  60. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_LINEAR** = ``0``
  61. Linear interpolation.
  62. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT:
  63. .. rst-class:: classref-enumeration-constant
  64. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_CONSTANT** = ``1``
  65. 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.
  66. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CUBIC:
  67. .. rst-class:: classref-enumeration-constant
  68. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_CUBIC** = ``2``
  69. Cubic interpolation.
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Property Descriptions
  74. ---------------------
  75. .. _class_Gradient_property_colors:
  76. .. rst-class:: classref-property
  77. :ref:`PoolColorArray<class_PoolColorArray>` **colors** = ``PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )``
  78. .. rst-class:: classref-property-setget
  79. - void **set_colors** **(** :ref:`PoolColorArray<class_PoolColorArray>` value **)**
  80. - :ref:`PoolColorArray<class_PoolColorArray>` **get_colors** **(** **)**
  81. Gradient's colors returned as a :ref:`PoolColorArray<class_PoolColorArray>`.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_Gradient_property_interpolation_mode:
  85. .. rst-class:: classref-property
  86. :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **interpolation_mode** = ``0``
  87. .. rst-class:: classref-property-setget
  88. - void **set_interpolation_mode** **(** :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` value **)**
  89. - :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **get_interpolation_mode** **(** **)**
  90. Defines how the colors between points of the gradient are interpolated. See :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` for available modes.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_Gradient_property_offsets:
  94. .. rst-class:: classref-property
  95. :ref:`PoolRealArray<class_PoolRealArray>` **offsets** = ``PoolRealArray( 0, 1 )``
  96. .. rst-class:: classref-property-setget
  97. - void **set_offsets** **(** :ref:`PoolRealArray<class_PoolRealArray>` value **)**
  98. - :ref:`PoolRealArray<class_PoolRealArray>` **get_offsets** **(** **)**
  99. Gradient's offsets returned as a :ref:`PoolRealArray<class_PoolRealArray>`.
  100. .. rst-class:: classref-section-separator
  101. ----
  102. .. rst-class:: classref-descriptions-group
  103. Method Descriptions
  104. -------------------
  105. .. _class_Gradient_method_add_point:
  106. .. rst-class:: classref-method
  107. void **add_point** **(** :ref:`float<class_float>` offset, :ref:`Color<class_Color>` color **)**
  108. Adds the specified color to the end of the ramp, with the specified offset.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_Gradient_method_get_color:
  112. .. rst-class:: classref-method
  113. :ref:`Color<class_Color>` **get_color** **(** :ref:`int<class_int>` point **)**
  114. Returns the color of the ramp color at index ``point``.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_Gradient_method_get_offset:
  118. .. rst-class:: classref-method
  119. :ref:`float<class_float>` **get_offset** **(** :ref:`int<class_int>` point **)**
  120. Returns the offset of the ramp color at index ``point``.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_Gradient_method_get_point_count:
  124. .. rst-class:: classref-method
  125. :ref:`int<class_int>` **get_point_count** **(** **)** |const|
  126. Returns the number of colors in the ramp.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_Gradient_method_interpolate:
  130. .. rst-class:: classref-method
  131. :ref:`Color<class_Color>` **interpolate** **(** :ref:`float<class_float>` offset **)**
  132. Returns the interpolated color specified by ``offset``.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_Gradient_method_remove_point:
  136. .. rst-class:: classref-method
  137. void **remove_point** **(** :ref:`int<class_int>` point **)**
  138. Removes the color at the index ``point``.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_Gradient_method_set_color:
  142. .. rst-class:: classref-method
  143. void **set_color** **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)**
  144. Sets the color of the ramp color at index ``point``.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_Gradient_method_set_offset:
  148. .. rst-class:: classref-method
  149. void **set_offset** **(** :ref:`int<class_int>` point, :ref:`float<class_float>` offset **)**
  150. Sets the offset for the ramp color at index ``point``.
  151. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  152. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  153. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  154. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`