:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Gradient.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Gradient: Gradient ======== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` A color interpolator resource which can be used to generate colors between user-defined color points. 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. Properties ---------- +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`PackedColorArray` | :ref:`colors` | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`InterpolationMode` | :ref:`interpolation_mode` | ``0`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ | :ref:`PackedFloat32Array` | :ref:`offsets` | ``PackedFloat32Array(0, 1)`` | +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+ Methods ------- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | 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:`reverse` **(** **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_color` **(** :ref:`int` point, :ref:`Color` color **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_offset` **(** :ref:`int` point, :ref:`float` offset **)** | +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+ Enumerations ------------ .. _enum_Gradient_InterpolationMode: .. _class_Gradient_constant_GRADIENT_INTERPOLATE_LINEAR: .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT: .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CUBIC: enum **InterpolationMode**: - **GRADIENT_INTERPOLATE_LINEAR** = **0** --- Linear interpolation. - **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. - **GRADIENT_INTERPOLATE_CUBIC** = **2** --- Cubic interpolation. Property Descriptions --------------------- .. _class_Gradient_property_colors: - :ref:`PackedColorArray` **colors** +-----------+----------------------------------------------+ | *Default* | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` | +-----------+----------------------------------------------+ | *Setter* | set_colors(value) | +-----------+----------------------------------------------+ | *Getter* | get_colors() | +-----------+----------------------------------------------+ Gradient's colors returned as a :ref:`PackedColorArray`. ---- .. _class_Gradient_property_interpolation_mode: - :ref:`InterpolationMode` **interpolation_mode** +-----------+-------------------------------+ | *Default* | ``0`` | +-----------+-------------------------------+ | *Setter* | set_interpolation_mode(value) | +-----------+-------------------------------+ | *Getter* | get_interpolation_mode() | +-----------+-------------------------------+ Defines how the colors between points of the gradient are interpolated. See :ref:`InterpolationMode` for available modes. ---- .. _class_Gradient_property_offsets: - :ref:`PackedFloat32Array` **offsets** +-----------+------------------------------+ | *Default* | ``PackedFloat32Array(0, 1)`` | +-----------+------------------------------+ | *Setter* | set_offsets(value) | +-----------+------------------------------+ | *Getter* | get_offsets() | +-----------+------------------------------+ Gradient's offsets returned as a :ref:`PackedFloat32Array`. Method Descriptions ------------------- .. _class_Gradient_method_add_point: - void **add_point** **(** :ref:`float` offset, :ref:`Color` color **)** Adds the specified color to the end of the gradient, with the specified offset. ---- .. _class_Gradient_method_get_color: - :ref:`Color` **get_color** **(** :ref:`int` point **)** Returns the color of the gradient color at index ``point``. ---- .. _class_Gradient_method_get_offset: - :ref:`float` **get_offset** **(** :ref:`int` point **)** Returns the offset of the gradient color at index ``point``. ---- .. _class_Gradient_method_get_point_count: - :ref:`int` **get_point_count** **(** **)** |const| Returns the number of colors in the gradient. ---- .. _class_Gradient_method_interpolate: - :ref:`Color` **interpolate** **(** :ref:`float` offset **)** Returns the interpolated color specified by ``offset``. ---- .. _class_Gradient_method_remove_point: - void **remove_point** **(** :ref:`int` point **)** Removes the color at the index ``point``. ---- .. _class_Gradient_method_reverse: - void **reverse** **(** **)** Reverses/mirrors the gradient. ---- .. _class_Gradient_method_set_color: - void **set_color** **(** :ref:`int` point, :ref:`Color` color **)** Sets the color of the gradient color at index ``point``. ---- .. _class_Gradient_method_set_offset: - void **set_offset** **(** :ref:`int` point, :ref:`float` offset **)** Sets the offset for the gradient 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.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`