Gradient

package
v0.0.0-...-9b8b246 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 25 Imported by: 0

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

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 Any

type Any interface {
	gd.IsClass
	AsGradient() Instance
}

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

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

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 (self *Extension[T]) AsGradient() Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

type ID

type ID Object.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.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Gradient

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 New

func New() Instance

func (Instance) AddPoint

func (self Instance) AddPoint(offset Float.X, color Color.RGBA)

Adds the specified color to the gradient, with the specified offset.

func (Instance) AsGradient

func (self Instance) AsGradient() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) Colors

func (self Instance) Colors() []Color.RGBA

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) GetColor

func (self Instance) GetColor(point int) Color.RGBA

Returns the color of the gradient color at index 'point'.

func (Instance) GetOffset

func (self Instance) GetOffset(point int) Float.X

Returns the offset of the gradient color at index 'point'.

func (Instance) GetPointCount

func (self Instance) GetPointCount() int

Returns the number of colors in the gradient.

func (Instance) ID

func (self Instance) ID() ID

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

func (self Instance) Offsets() []float32

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

func (self Instance) RemovePoint(point int)

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

func (self Instance) Sample(offset Float.X) Color.RGBA

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) SetColor

func (self Instance) SetColor(point int, color Color.RGBA)

Sets the color of the gradient color at index 'point'.

func (Instance) SetColors

func (self Instance) SetColors(value []Color.RGBA)

SetColors sets the property returned by [GetColors].

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) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOffset

func (self Instance) SetOffset(point int, offset Float.X)

Sets the offset for the gradient color at index 'point'.

func (Instance) SetOffsets

func (self Instance) SetOffsets(value []float32)

SetOffsets sets the property returned by [GetOffsets].

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL