Gradient
A color transition.
Gradient.swift:20class Gradient
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.
Superclasses
class Resource
Base class for serializable objects.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
Instance members
var colors: PackedColorArray
Gradient’s colors as a
PackedColorArray
.var interpolationColorSpace: Gradient.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. See
ColorSpace
for available modes.var interpolationMode: Gradient.InterpolationMode
The algorithm used to interpolate between points of the gradient. See
InterpolationMode
for available modes.var offsets: PackedFloat32Array
Gradient’s offsets as a
PackedFloat32Array
.func addPoint(offset: Double, color: Color
) Adds the specified color to the gradient, with the specified offset.
func getColor(point: Int32
) -> Color Returns the color of the gradient color at index
point
.func getOffset(point: Int32
) -> Double Returns the offset of the gradient color at index
point
.func getPointCount(
) -> Int32 Returns the number of colors in the gradient.
func removePoint(Int32
) Removes the color at index
point
.func reverse(
) Reverses/mirrors the gradient.
func sample(offset: Double
) -> Color Returns the interpolated color specified by
offset
.func setColor(point: Int32, color: Color
) Sets the color of the gradient color at index
point
.func setOffset(point: Int32, offset: Double
) Sets the offset for the gradient color at index
point
.