123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/Gradient.xml.
- .. _class_Gradient:
- Gradient
- ========
- **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_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<class_Curve>` which supports more complex easing methods, but does not support colors.
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
- | :ref:`PackedColorArray<class_PackedColorArray>` | :ref:`colors<class_Gradient_property_colors>` | ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)`` |
- +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
- | :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` | :ref:`interpolation_mode<class_Gradient_property_interpolation_mode>` | ``0`` |
- +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
- | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`offsets<class_Gradient_property_offsets>` | ``PackedFloat32Array(0, 1)`` |
- +-----------------------------------------------------------+-----------------------------------------------------------------------+----------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`add_point<class_Gradient_method_add_point>` **(** :ref:`float<class_float>` offset, :ref:`Color<class_Color>` color **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Color<class_Color>` | :ref:`get_color<class_Gradient_method_get_color>` **(** :ref:`int<class_int>` point **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`get_offset<class_Gradient_method_get_offset>` **(** :ref:`int<class_int>` point **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get_point_count<class_Gradient_method_get_point_count>` **(** **)** |const| |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`remove_point<class_Gradient_method_remove_point>` **(** :ref:`int<class_int>` point **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`reverse<class_Gradient_method_reverse>` **(** **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`Color<class_Color>` | :ref:`sample<class_Gradient_method_sample>` **(** :ref:`float<class_float>` offset **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_color<class_Gradient_method_set_color>` **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)** |
- +---------------------------+---------------------------------------------------------------------------------------------------------------------------------+
- | void | :ref:`set_offset<class_Gradient_method_set_offset>` **(** :ref:`int<class_int>` point, :ref:`float<class_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<enum_Gradient_InterpolationMode>` **GRADIENT_INTERPOLATE_LINEAR** = ``0``
- Linear interpolation.
- .. _class_Gradient_constant_GRADIENT_INTERPOLATE_CONSTANT:
- .. rst-class:: classref-enumeration-constant
- :ref:`InterpolationMode<enum_Gradient_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<enum_Gradient_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:`PackedColorArray<class_PackedColorArray>` **colors** = ``PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)``
- .. rst-class:: classref-property-setget
- - void **set_colors** **(** :ref:`PackedColorArray<class_PackedColorArray>` value **)**
- - :ref:`PackedColorArray<class_PackedColorArray>` **get_colors** **(** **)**
- Gradient's colors returned as a :ref:`PackedColorArray<class_PackedColorArray>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_property_interpolation_mode:
- .. rst-class:: classref-property
- :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **interpolation_mode** = ``0``
- .. rst-class:: classref-property-setget
- - void **set_interpolation_mode** **(** :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` value **)**
- - :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` **get_interpolation_mode** **(** **)**
- Defines how the colors between points of the gradient are interpolated. See :ref:`InterpolationMode<enum_Gradient_InterpolationMode>` for available modes.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_property_offsets:
- .. rst-class:: classref-property
- :ref:`PackedFloat32Array<class_PackedFloat32Array>` **offsets** = ``PackedFloat32Array(0, 1)``
- .. rst-class:: classref-property-setget
- - void **set_offsets** **(** :ref:`PackedFloat32Array<class_PackedFloat32Array>` value **)**
- - :ref:`PackedFloat32Array<class_PackedFloat32Array>` **get_offsets** **(** **)**
- Gradient's offsets returned as a :ref:`PackedFloat32Array<class_PackedFloat32Array>`.
- .. 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<class_float>` offset, :ref:`Color<class_Color>` color **)**
- Adds the specified color to the end of the gradient, with the specified offset.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_get_color:
- .. rst-class:: classref-method
- :ref:`Color<class_Color>` **get_color** **(** :ref:`int<class_int>` point **)**
- Returns the color of the gradient color at index ``point``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_get_offset:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **get_offset** **(** :ref:`int<class_int>` point **)**
- Returns the offset of the gradient color at index ``point``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_get_point_count:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get_point_count** **(** **)** |const|
- Returns the number of colors in the gradient.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_remove_point:
- .. rst-class:: classref-method
- void **remove_point** **(** :ref:`int<class_int>` point **)**
- Removes the color at the index ``point``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_reverse:
- .. rst-class:: classref-method
- void **reverse** **(** **)**
- Reverses/mirrors the gradient.
- \ **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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_sample:
- .. rst-class:: classref-method
- :ref:`Color<class_Color>` **sample** **(** :ref:`float<class_float>` offset **)**
- Returns the interpolated color specified by ``offset``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_set_color:
- .. rst-class:: classref-method
- void **set_color** **(** :ref:`int<class_int>` point, :ref:`Color<class_Color>` color **)**
- Sets the color of the gradient color at index ``point``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_Gradient_method_set_offset:
- .. rst-class:: classref-method
- void **set_offset** **(** :ref:`int<class_int>` point, :ref:`float<class_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.)`
|