Documentation
¶
Overview ¶
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.
Index ¶
- type Advanced
- type Any
- type ColorSpace
- type Extension
- type ID
- type Instance
- func (self Instance) AddPoint(offset Float.X, color Color.RGBA)
- func (self Instance) AsGradient() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsResource() Resource.Instance
- func (self Instance) Colors() []Color.RGBA
- func (self Instance) GetColor(point int) Color.RGBA
- func (self Instance) GetOffset(point int) Float.X
- func (self Instance) GetPointCount() int
- func (self Instance) ID() ID
- func (self Instance) InterpolationColorSpace() ColorSpace
- func (self Instance) InterpolationMode() InterpolationMode
- func (self Instance) Offsets() []float32
- func (self Instance) RemovePoint(point int)
- func (self Instance) Reverse()
- func (self Instance) Sample(offset Float.X) Color.RGBA
- func (self Instance) SetColor(point int, color Color.RGBA)
- func (self Instance) SetColors(value []Color.RGBA)
- func (self Instance) SetInterpolationColorSpace(value ColorSpace)
- func (self Instance) SetInterpolationMode(value InterpolationMode)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOffset(point int, offset Float.X)
- func (self Instance) SetOffsets(value []float32)
- func (self Instance) Virtual(name string) reflect.Value
- type InterpolationMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type ColorSpace ¶
type ColorSpace int //gd:Gradient.ColorSpace
const ( // sRGB color space. GradientColorSpaceSrgb ColorSpace = 0 // Linear sRGB color space. GradientColorSpaceLinearSrgb ColorSpace = 1 // [Oklab] color space. This color space provides a smooth and uniform-looking transition between colors. // // [Oklab]: https://bottosson.github.io/posts/oklab/ GradientColorSpaceOklab ColorSpace = 2 )
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsGradient ¶
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsResource ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsGradient ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsResource ¶
func (Instance) Colors ¶
Gradient's colors as a []Color.RGBA.
Note: Setting this property updates all colors at once. To update any color individually use SetColor.
func (Instance) GetPointCount ¶
Returns the number of colors in the gradient.
func (Instance) InterpolationColorSpace ¶
func (self Instance) InterpolationColorSpace() ColorSpace
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.
Note: This setting has no effect when InterpolationMode is set to GradientInterpolateConstant.
func (Instance) InterpolationMode ¶
func (self Instance) InterpolationMode() InterpolationMode
The algorithm used to interpolate between points of the gradient.
func (Instance) Offsets ¶
Gradient's offsets as a []float32.
Note: Setting this property updates all offsets at once. To update any offset individually use SetOffset.
func (Instance) RemovePoint ¶
Removes the color at index 'point'.
func (Instance) Reverse ¶
func (self Instance) 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 GradientInterpolateConstant.
func (Instance) Sample ¶
Returns the interpolated color specified by 'offset'. 'offset' should be between 0.0 and 1.0 (inclusive). Using a value lower than 0.0 will return the same color as 0.0, and using a value higher than 1.0 will return the same color as 1.0. If your input value is not within this range, consider using @GlobalScope.Remap on the input value with output values set to 0.0 and 1.0.
func (Instance) SetInterpolationColorSpace ¶
func (self Instance) SetInterpolationColorSpace(value ColorSpace)
SetInterpolationColorSpace sets the property returned by [GetInterpolationColorSpace].
func (Instance) SetInterpolationMode ¶
func (self Instance) SetInterpolationMode(value InterpolationMode)
SetInterpolationMode sets the property returned by [GetInterpolationMode].
func (Instance) SetOffsets ¶
SetOffsets sets the property returned by [GetOffsets].
type InterpolationMode ¶
type InterpolationMode int //gd:Gradient.InterpolationMode
const ( // Linear interpolation. GradientInterpolateLinear InterpolationMode = 0 // 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. GradientInterpolateConstant InterpolationMode = 1 // Cubic interpolation. GradientInterpolateCubic InterpolationMode = 2 )