:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Gradient.xml. .. _class_Gradient: Gradient ======== **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` A color interpolator resource which can be used to generate colors between user-defined color points. .. rst-class:: classref-introduction-group Description ----------- 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. See also :ref:`Curve` which supports more complex easing methods, but does not support colors. .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`PoolColorArray` | :ref:`colors` | ``PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`InterpolationMode` | :ref:`interpolation_mode` | ``0`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`PoolRealArray` | :ref:`offsets` | ``PoolRealArray( 0, 1 )`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_point` **(** :ref:`float` offset, :ref:`Color` color **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`get_color` **(** :ref:`int` point **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`get_offset` **(** :ref:`int` point **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_point_count` **(** **)** |const| | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`interpolate` **(** :ref:`float` offset **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_point` **(** :ref:`int` point **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_color` **(** :ref:`int` point, :ref:`Color` color **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_offset` **(** :ref:`int` point, :ref:`float` offset **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Enumerations ------------ .. _enum_Gradient_InterpolationMode: .. rst-class:: classref-enumeration enum **InterpolationMode**: .. _class_Gradient_constant_GRADIENT_INTERPOLATE_LINEAR: .. rst-class:: classref-enumeration-constant :ref:`InterpolationMode` **GRADIENT_INTERPOLATE_LINEAR** = ``0`` Linear interpolation. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT: .. rst-class:: classref-enumeration-constant :ref:`InterpolationMode` **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. .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CUBIC: .. rst-class:: classref-enumeration-constant :ref:`InterpolationMode` **GRADIENT_INTERPOLATE_CUBIC** = ``2`` Cubic interpolation. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Gradient_property_colors: .. rst-class:: classref-property :ref:`PoolColorArray` **colors** = ``PoolColorArray( 0, 0, 0, 1, 1, 1, 1, 1 )`` .. rst-class:: classref-property-setget - void **set_colors** **(** :ref:`PoolColorArray` value **)** - :ref:`PoolColorArray` **get_colors** **(** **)** Gradient's colors returned as a :ref:`PoolColorArray`. .. rst-class:: classref-item-separator ---- .. _class_Gradient_property_interpolation_mode: .. rst-class:: classref-property :ref:`InterpolationMode` **interpolation_mode** = ``0`` .. rst-class:: classref-property-setget - void **set_interpolation_mode** **(** :ref:`InterpolationMode` value **)** - :ref:`InterpolationMode` **get_interpolation_mode** **(** **)** Defines how the colors between points of the gradient are interpolated. See :ref:`InterpolationMode` for available modes. .. rst-class:: classref-item-separator ---- .. _class_Gradient_property_offsets: .. rst-class:: classref-property :ref:`PoolRealArray` **offsets** = ``PoolRealArray( 0, 1 )`` .. rst-class:: classref-property-setget - void **set_offsets** **(** :ref:`PoolRealArray` value **)** - :ref:`PoolRealArray` **get_offsets** **(** **)** Gradient's offsets returned as a :ref:`PoolRealArray`. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Gradient_method_add_point: .. rst-class:: classref-method void **add_point** **(** :ref:`float` offset, :ref:`Color` color **)** Adds the specified color to the end of the ramp, with the specified offset. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_get_color: .. rst-class:: classref-method :ref:`Color` **get_color** **(** :ref:`int` point **)** Returns the color of the ramp color at index ``point``. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_get_offset: .. rst-class:: classref-method :ref:`float` **get_offset** **(** :ref:`int` point **)** Returns the offset of the ramp color at index ``point``. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_get_point_count: .. rst-class:: classref-method :ref:`int` **get_point_count** **(** **)** |const| Returns the number of colors in the ramp. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_interpolate: .. rst-class:: classref-method :ref:`Color` **interpolate** **(** :ref:`float` offset **)** Returns the interpolated color specified by ``offset``. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_remove_point: .. rst-class:: classref-method void **remove_point** **(** :ref:`int` point **)** Removes the color at the index ``point``. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_set_color: .. rst-class:: classref-method void **set_color** **(** :ref:`int` point, :ref:`Color` color **)** Sets the color of the ramp color at index ``point``. .. rst-class:: classref-item-separator ---- .. _class_Gradient_method_set_offset: .. rst-class:: classref-method void **set_offset** **(** :ref:`int` point, :ref:`float` offset **)** Sets the offset for the ramp color at index ``point``. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`