Class ColorAnimationTextGradient
Represents a color gradient for animated text effects. Provides smooth interpolation between colors and includes preset gradient definitions.
Inherited Members
Namespace: Scylla.Core.Util.Effects
Assembly: ScyllaCore.dll
Syntax
public sealed class ColorAnimationTextGradient
Remarks
Colors are stored immutably. The constructor performs a defensive copy of the supplied array, and the Colors property returns a new defensive copy on every access. Callers should prefer GetColor(int) or GetColorAt(float) when they only need individual color values, to avoid the allocation cost.
Two interpolation modes are available:
- GetColorAt(float) - clamped, non-wrapping. Positions outside 0-1 are clamped to the first or last color.
- GetColorAtWrapped(float) - wrapping mode for seamless loops. The last color blends back into the first color, making this suitable for cyclic animations driven by ColorAnimationText.
Ten preset gradients are available as static properties (OceanBlues, SunsetReds, ForestGreens, RoyalPurples, GoldenYellows, CyanTeals, CoralPinks, SilverGrays, MagentaViolets, AmberBrowns). Each preset is lazily initialized on first access and cached for the lifetime of the application.
This class is designed for use with ColorAnimationText but can also be used standalone wherever smooth multi-stop color interpolation is needed.
Constructors
ColorAnimationTextGradient(params Color[])
Creates a new ColorAnimationTextGradient with the specified color stops.
Declaration
public ColorAnimationTextGradient(params Color[] colors)
Parameters
| Type | Name | Description |
|---|---|---|
| Color[] | colors | The color stops that define this gradient, in order from the first stop (position 0.0) to the last stop (position 1.0). Must be non-null and contain at least 2 colors. |
Remarks
The constructor performs a defensive copy of the supplied array. Subsequent modifications to the original array will not affect this gradient. A minimum of 2 colors is required to guarantee that interpolation between adjacent stops is meaningful - a single-color gradient would produce no visible wave effect when used with ColorAnimationText.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
Properties
AmberBrowns
Gets the Amber Browns preset gradient (dark brown to amber).
Declaration
public static ColorAnimationTextGradient AmberBrowns { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that ascends from a dark earthy brown through warm tan and sienna tones to a bright amber. Suitable for wood, earth, or autumn-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark earthy brown (approximately #664019) through warm sienna and tan tones to bright amber (approximately #F2BF73). The instance is created lazily on first access and cached for all subsequent calls.
ColorCount
Gets the number of colors in this gradient.
Declaration
public int ColorCount { get; }
Property Value
| Type | Description |
|---|---|
| int | The total number of color stops stored in the gradient. Always at least 2, as enforced by the constructor. |
Remarks
The constructor requires a minimum of 2 colors to guarantee that meaningful interpolation
is possible across the gradient range. ColorCount will therefore never be less
than 2 on a valid instance.
Colors
Gets a defensive copy of the full colors array.
Declaration
public Color[] Colors { get; }
Property Value
| Type | Description |
|---|---|
| Color[] | A new UnityEngine.Color array containing all color stops in order from the first stop (index 0) to the last. |
Remarks
Each access allocates a new array and copies all color values. For high-frequency or hot-path usage, prefer GetColor(int) to retrieve individual colors by index, or GetColorAt(float) / GetColorAtWrapped(float) for interpolated lookups - none of which allocate.
CoralPinks
Gets the Coral Pinks preset gradient (deep pink to light coral).
Declaration
public static ColorAnimationTextGradient CoralPinks { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that progresses from a vivid deep rose through warm coral tones to a soft blush pink. Suitable for romantic, floral, or candy-themed animations. |
Remarks
This preset contains 5 color stops ranging from deep rose-pink (approximately #BF4066) through coral red and warm salmon tones to soft blush pink (approximately #FFCCD1). The instance is created lazily on first access and cached for all subsequent calls.
CyanTeals
Gets the Cyan Teals preset gradient (deep teal to light cyan).
Declaration
public static ColorAnimationTextGradient CyanTeals { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that transitions from a dark blue-green teal through mid-tones to a near-white pale cyan. Suitable for ice, tech, or aqua-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark blue-green teal (approximately #0D6673) through mid-teal and bright cyan tones to a near-white pale cyan (approximately #8CF2FA). The instance is created lazily on first access and cached for all subsequent calls.
ForestGreens
Gets the Forest Greens preset gradient (dark to bright green).
Declaration
public static ColorAnimationTextGradient ForestGreens { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that rises from a deep forest green through mid-leaf greens to a bright spring green. Suitable for nature, growth, or health-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark forest green (approximately #1A5926) through mid-canopy greens to a bright spring green (approximately #8CE680). The instance is created lazily on first access and cached for all subsequent calls.
GoldenYellows
Gets the Golden Yellows preset gradient (amber to bright yellow).
Declaration
public static ColorAnimationTextGradient GoldenYellows { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that progresses from a warm dark amber through golden tones to a bright pale yellow. Suitable for treasure, sunlight, or energy-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark amber-gold (approximately #B38019) through rich gold and warm yellows to bright pale yellow (approximately #FFF280). The instance is created lazily on first access and cached for all subsequent calls.
this[int]
Returns the exact color stop at the given index, with no interpolation.
Declaration
public Color this[int index] { get; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the color stop to retrieve. Must be in the range
|
Property Value
| Type | Description |
|---|---|
| Color | The UnityEngine.Color stored at |
Remarks
This indexer is equivalent to calling GetColor(int)(index) directly.
It exists for syntactic convenience when treating the gradient as a readable collection.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
MagentaViolets
Gets the Magenta Violets preset gradient (deep magenta to light violet).
Declaration
public static ColorAnimationTextGradient MagentaViolets { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that progresses from a saturated deep magenta through bright pink-violet tones to a pale orchid. Suitable for neon, synthwave, or fantasy-themed animations. |
Remarks
This preset contains 5 color stops ranging from deep saturated magenta (approximately #8C1A73) through vivid pink-violet tones to pale orchid (approximately #FFB2F2). The instance is created lazily on first access and cached for all subsequent calls.
OceanBlues
Gets the Ocean Blues preset gradient (deep to light blue).
Declaration
public static ColorAnimationTextGradient OceanBlues { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that ranges from a dark navy blue through two mid-ocean blues to a pale sky blue. Suitable for underwater, aquatic, or cool-sky themed animations. |
Remarks
This preset contains 5 color stops ranging from deep navy (approximately #1A4DA6) through medium and mid-ocean blues to light sky blue (approximately #8DCCFF). The instance is created lazily on first access and cached for all subsequent calls.
PresetCount
Gets the total number of built-in preset gradients available on this class.
Declaration
public static int PresetCount { get; }
Property Value
| Type | Description |
|---|---|
| int | Always |
Remarks
This value is a compile-time constant expression. Accessing it does not trigger the lazy initialization of any preset gradient, unlike GetAllPresets().
RoyalPurples
Gets the Royal Purples preset gradient (deep to light purple).
Declaration
public static ColorAnimationTextGradient RoyalPurples { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that ascends from a deep indigo through mid-violet to a soft lavender. Suitable for magical, arcane, or regal-themed animations. |
Remarks
This preset contains 5 color stops ranging from deep indigo-purple (approximately #4D1A80) through royal violet and mid-purple tones to soft lavender (approximately #D9A6F2). The instance is created lazily on first access and cached for all subsequent calls.
SilverGrays
Gets the Silver Grays preset gradient (dark to light gray).
Declaration
public static ColorAnimationTextGradient SilverGrays { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that rises from a dark charcoal through neutral grays to a near-white silver. Suitable for metallic, monochrome, or minimalist-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark charcoal gray (approximately #4D5259) through balanced mid-gray tones to near-white silver (approximately #E0E6EB). The instance is created lazily on first access and cached for all subsequent calls.
SunsetReds
Gets the Sunset Reds preset gradient (deep red to orange).
Declaration
public static ColorAnimationTextGradient SunsetReds { get; }
Property Value
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A 5-color gradient that transitions from a dark crimson through deep red and burnt orange to a warm amber-orange. Suitable for fire, lava, or sunset-themed animations. |
Remarks
This preset contains 5 color stops ranging from dark crimson (approximately #A61F26) through ember reds and deep orange tones to warm amber-orange (approximately #FFA65A). The instance is created lazily on first access and cached for all subsequent calls.
Methods
Create(params Color[])
Creates a new ColorAnimationTextGradient from the specified color stops.
Declaration
public static ColorAnimationTextGradient Create(params Color[] colors)
Parameters
| Type | Name | Description |
|---|---|---|
| Color[] | colors | The color stops that define the gradient. Must be non-null and contain at least 2 colors. Accepts a params array for concise inline usage. |
Returns
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A new ColorAnimationTextGradient instance. |
Remarks
This factory method is a convenience wrapper around the constructor.
var gradient = ColorAnimationTextGradient.Create(Color.red, Color.yellow, Color.white);
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
CreateFromHex(params string[])
Creates a new ColorAnimationTextGradient from an array of hex color strings.
Declaration
public static ColorAnimationTextGradient CreateFromHex(params string[] hexColors)
Parameters
| Type | Name | Description |
|---|---|---|
| string[] | hexColors | The hex color strings defining each color stop. Each string may optionally include a
leading |
Returns
| Type | Description |
|---|---|
| ColorAnimationTextGradient | A new ColorAnimationTextGradient instance. |
Remarks
Hex parsing is performed by Unity's ColorUtility.TryParseHtmlString. The method
normalizes each string by stripping a leading # and then re-adding it before
passing to the parser, so both formats are accepted interchangeably. Standard 6-digit RGB
(RRGGBB) and 8-digit RGBA (RRGGBBAA) formats are supported.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ArgumentException | Thrown if |
GetAllPresets()
Returns a new array containing all 10 built-in preset gradients.
Declaration
public static ColorAnimationTextGradient[] GetAllPresets()
Returns
| Type | Description |
|---|---|
| ColorAnimationTextGradient[] | A newly allocated array of length 10, containing OceanBlues, SunsetReds, ForestGreens, RoyalPurples, GoldenYellows, CyanTeals, CoralPinks, SilverGrays, MagentaViolets, and AmberBrowns in that order. |
Remarks
Each call allocates a new array. If all 10 presets have not yet been accessed, calling this method also triggers their lazy initialization. For a constant count without allocation, use PresetCount instead.
GetColor(int)
Returns the exact color stop stored at the given index, with no interpolation.
Declaration
public Color GetColor(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The zero-based index of the color stop to retrieve. Must be in the range
|
Returns
| Type | Description |
|---|---|
| Color | The UnityEngine.Color stored at |
Remarks
This method does not allocate and returns the raw stored value directly.
It is equivalent to using the indexer (gradient[index]). For an interpolated
color at a normalized position, use GetColorAt(float) instead.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
GetColorAt(float)
Returns a smoothly interpolated color at the given normalized position within the gradient.
Declaration
public Color GetColorAt(float normalizedPosition)
Parameters
| Type | Name | Description |
|---|---|---|
| float | normalizedPosition | The position along the gradient, where |
Returns
| Type | Description |
|---|---|
| Color | The linearly interpolated UnityEngine.Color between the two adjacent color
stops that bracket the requested position. Returns the first color stop if
|
Remarks
The algorithm divides the 0-1 range into (ColorCount - 1) equal
segments, identifies which segment the requested position falls into, and performs a
linear interpolation (Color.Lerp) between the two bounding color stops.
This method clamps out-of-range positions and does NOT wrap. For a looping/wrapping animation where the last color should blend back into the first, use GetColorAtWrapped(float) instead.
GetColorAtWrapped(float)
Returns a smoothly interpolated color using wrapping mode, enabling seamless looping animations where the last color blends continuously back into the first.
Declaration
public Color GetColorAtWrapped(float position)
Parameters
| Type | Name | Description |
|---|---|---|
| float | position | The position along the gradient. Any value is valid - the fractional part is used after
wrapping via |
Returns
| Type | Description |
|---|---|
| Color | The linearly interpolated UnityEngine.Color at the wrapped position. At position 0.0 (and 1.0, 2.0, etc.) the method returns the first color stop. As position approaches the next whole number, the last color blends back into the first color, producing a seamless loop. |
Remarks
The wrapping algorithm maps the full color array - including a final implicit segment
from the last stop back to the first - across the 0-1 range. Specifically, position is
scaled by ColorCount (not ColorCount - 1) so the final segment
covers the range from the last color to the first, making the gradient circular.
This is the method used internally by ColorAnimationText for all direction modes, because animation progress naturally cycles through 0-1 repeatedly. Use GetColorAt(float) instead when clamping to the endpoints is the desired behavior.