Class Gradient
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class Gradient : Resource, IDisposable
- Inheritance
-
Gradient
- Implements
- Inherited Members
Constructors
Gradient()
public Gradient()
Properties
Colors
Gradient's colors returned as a Color[].
Note: This property returns a copy, modifying the return value does not update the gradient. To update the gradient use SetColor(int, Color) method (for updating colors individually) or assign to this property directly (for bulk-updating all colors at once).
public Color[] Colors { get; set; }
Property Value
- Color[]
InterpolationColorSpace
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 Gradient.ColorSpace for available modes.
Note: This setting has no effect when InterpolationMode is set to Constant.
public Gradient.ColorSpace InterpolationColorSpace { get; set; }
Property Value
InterpolationMode
The algorithm used to interpolate between points of the gradient. See Gradient.InterpolationModeEnum for available modes.
public Gradient.InterpolationModeEnum InterpolationMode { get; set; }
Property Value
Offsets
Gradient's offsets returned as a float[].
Note: This property returns a copy, modifying the return value does not update the gradient. To update the gradient use SetOffset(int, float) method (for updating offsets individually) or assign to this property directly (for bulk-updating all offsets at once).
public float[] Offsets { get; set; }
Property Value
- float[]
Methods
AddPoint(float, Color)
Adds the specified color to the gradient, with the specified offset.
public void AddPoint(float offset, Color color)
Parameters
GetColor(int)
Returns the color of the gradient color at index point
.
public Color GetColor(int point)
Parameters
point
int
Returns
GetOffset(int)
Returns the offset of the gradient color at index point
.
public float GetOffset(int point)
Parameters
point
int
Returns
GetPointCount()
Returns the number of colors in the gradient.
public int GetPointCount()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
RemovePoint(int)
Removes the color at index point
.
public void RemovePoint(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 InterpolationMode is set to Constant.
public void Reverse()
Sample(float)
Returns the interpolated color specified by offset
.
public Color Sample(float offset)
Parameters
offset
float
Returns
SetColor(int, Color)
Sets the color of the gradient color at index point
.
public void SetColor(int point, Color color)
Parameters
SetOffset(int, float)
Sets the offset for the gradient color at index point
.
public void SetOffset(int point, float offset)