Class Gradient
A color transition.
- Inheritance
-
Gradient
Remarks
This resource describes a color transition by defining a set of colored points and how to interpolate between them.
See also Curve which supports more complex easing methods, but does not support colors.
Properties
colors
Gradient's colors as a PackedColorArray.
Note: Setting this property updates all colors at once. To update any color individually use Gradient.set_color.
var colors : PackedColorArray = PackedColorArray(0, 0, 0, 1, 1, 1, 1, 1)
Property Value
Remarks
- void set_colors(PackedColorArray value)
- PackedColorArray get_colors
interpolation_color_space
The color space used to interpolate between points of the gradient. It does not affect the returned colors, which will always be in sRGB space. See ColorSpace for available modes.
Note: This setting has no effect when interpolation_mode is set to Gradient.GRADIENT_INTERPOLATE_CONSTANT.
var interpolation_color_space : int = 0
Property Value
Remarks
interpolation_mode
The algorithm used to interpolate between points of the gradient. See InterpolationMode for available modes.
var interpolation_mode : int = 0
Property Value
Remarks
offsets
Gradient's offsets as a PackedFloat32Array.
Note: Setting this property updates all offsets at once. To update any offset individually use Gradient.set_offset.
var offsets : PackedFloat32Array = PackedFloat32Array(0, 1)
Property Value
Remarks
- void set_offsets(PackedFloat32Array value)
- PackedFloat32Array get_offsets
Methods
add_point(float, Color)
Adds the specified color to the gradient, with the specified offset.
void add_point(float offset, Color color)
Parameters
get_color(int)
Returns the color of the gradient color at index point
.
Color get_color(int point)
Parameters
point
int
get_offset(int)
Returns the offset of the gradient color at index point
.
float get_offset(int point)
Parameters
point
int
get_point_count
Qualifiers: const
Returns the number of colors in the gradient.
int get_point_count
remove_point(int)
Removes the color at index point
.
void remove_point(int point)
Parameters
point
int
reverse
Reverses/mirrors the gradient.
Note: This method mirrors all points around the middle of the gradient, which may produce unexpected results when interpolation_mode is set to Gradient.GRADIENT_INTERPOLATE_CONSTANT.
void reverse
sample(float)
Returns the interpolated color specified by offset
.
Color sample(float offset)
Parameters
offset
float
set_color(int, Color)
Sets the color of the gradient color at index point
.
void set_color(int point, Color color)
Parameters
set_offset(int, float)
Sets the offset for the gradient color at index point
.
void set_offset(int point, float offset)