class_gradient.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the Gradient.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Gradient:
  6. Gradient
  7. ========
  8. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. A color interpolator resource which can be used to generate colors between user-defined color points.
  10. Description
  11. -----------
  12. 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.
  13. Properties
  14. ----------
  15. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  16. | :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`colors<class_Gradient_property_colors>` | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` |
  17. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  18. | :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` | :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` | ``0`` |
  19. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  20. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`offsets<class_Gradient_property_offsets>` | ``PackedFloat32Array(0, 1)`` |
  21. +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
  22. Methods
  23. -------
  24. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`add_point<class_Gradient_method_add_point>` **(** :ref:`float<class_float>` offset, :ref:`Color<class_Color>` color **)** |
  26. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`Color<class_Color>` | :ref:`get_color<class_Gradient_method_get_color>` **(** :ref:`int<class_int>` point **)** |
  28. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`get_offset<class_Gradient_method_get_offset>` **(** :ref:`int<class_int>` point **)** |
  30. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`get_point_count<class_Gradient_method_get_point_count>` **(** **)** |const| |
  32. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Color<class_Color>` | :ref:`interpolate<class_Gradient_method_interpolate>` **(** :ref:`float<class_float>` offset **)** |
  34. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`remove_point<class_Gradient_method_remove_point>` **(** :ref:`int<class_int>` point **)** |
  36. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`reverse<class_Gradient_method_reverse>` **(** **)** |
  38. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`set_color<class_Gradient_method_set_color>` **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)** |
  40. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`set_offset<class_Gradient_method_set_offset>` **(** :ref:`int<class_int>` point, :ref:`float<class_float>` offset **)** |
  42. +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
  43. Enumerations
  44. ------------
  45. .. _enum_Gradient_InterpolationMode:
  46. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_LINEAR:
  47. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT:
  48. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CUBIC:
  49. enum **InterpolationMode**:
  50. - **GRADIENT_INTERPOLATE_LINEAR** = **0** --- Linear interpolation.
  51. - **GRADIENT_INTERPOLATE_CONSTANT** = **1** --- 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.
  52. - **GRADIENT_INTERPOLATE_CUBIC** = **2** --- Cubic interpolation.
  53. Property Descriptions
  54. ---------------------
  55. .. _class_Gradient_property_colors:
  56. - :ref:`PackedColorArray<class_PackedColorArray>` **colors**
  57. +-----------+----------------------------------------------+
  58. | *Default* | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` |
  59. +-----------+----------------------------------------------+
  60. | *Setter* | set_colors(value) |
  61. +-----------+----------------------------------------------+
  62. | *Getter* | get_colors() |
  63. +-----------+----------------------------------------------+
  64. Gradient's colors returned as a :ref:`PackedColorArray<class_PackedColorArray>`.
  65. ----
  66. .. _class_Gradient_property_interpolation_mode:
  67. - :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **interpolation_mode**
  68. +-----------+-------------------------------+
  69. | *Default* | ``0`` |
  70. +-----------+-------------------------------+
  71. | *Setter* | set_interpolation_mode(value) |
  72. +-----------+-------------------------------+
  73. | *Getter* | get_interpolation_mode() |
  74. +-----------+-------------------------------+
  75. Defines how the colors between points of the gradient are interpolated. See :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` for available modes.
  76. ----
  77. .. _class_Gradient_property_offsets:
  78. - :ref:`PackedFloat32Array<class_PackedFloat32Array>` **offsets**
  79. +-----------+------------------------------+
  80. | *Default* | ``PackedFloat32Array(0, 1)`` |
  81. +-----------+------------------------------+
  82. | *Setter* | set_offsets(value) |
  83. +-----------+------------------------------+
  84. | *Getter* | get_offsets() |
  85. +-----------+------------------------------+
  86. Gradient's offsets returned as a :ref:`PackedFloat32Array<class_PackedFloat32Array>`.
  87. Method Descriptions
  88. -------------------
  89. .. _class_Gradient_method_add_point:
  90. - void **add_point** **(** :ref:`float<class_float>` offset, :ref:`Color<class_Color>` color **)**
  91. Adds the specified color to the end of the gradient, with the specified offset.
  92. ----
  93. .. _class_Gradient_method_get_color:
  94. - :ref:`Color<class_Color>` **get_color** **(** :ref:`int<class_int>` point **)**
  95. Returns the color of the gradient color at index ``point``.
  96. ----
  97. .. _class_Gradient_method_get_offset:
  98. - :ref:`float<class_float>` **get_offset** **(** :ref:`int<class_int>` point **)**
  99. Returns the offset of the gradient color at index ``point``.
  100. ----
  101. .. _class_Gradient_method_get_point_count:
  102. - :ref:`int<class_int>` **get_point_count** **(** **)** |const|
  103. Returns the number of colors in the gradient.
  104. ----
  105. .. _class_Gradient_method_interpolate:
  106. - :ref:`Color<class_Color>` **interpolate** **(** :ref:`float<class_float>` offset **)**
  107. Returns the interpolated color specified by ``offset``.
  108. ----
  109. .. _class_Gradient_method_remove_point:
  110. - void **remove_point** **(** :ref:`int<class_int>` point **)**
  111. Removes the color at the index ``point``.
  112. ----
  113. .. _class_Gradient_method_reverse:
  114. - void **reverse** **(** **)**
  115. Reverses/mirrors the gradient.
  116. ----
  117. .. _class_Gradient_method_set_color:
  118. - void **set_color** **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)**
  119. Sets the color of the gradient color at index ``point``.
  120. ----
  121. .. _class_Gradient_method_set_offset:
  122. - void **set_offset** **(** :ref:`int<class_int>` point, :ref:`float<class_float>` offset **)**
  123. Sets the offset for the gradient color at index ``point``.
  124. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  125. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  126. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  127. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  128. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  129. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`