Struct ColorGradientStop
Represents a single color stop within a ColorGradient. Each stop associates a normalized offset position (0-1) with an RGBA color value.
Inherited Members
Namespace: Scylla.Core.Util.Palette
Assembly: ScyllaCore.dll
Syntax
public readonly struct ColorGradientStop : IEquatable<ColorGradientStop>, IComparable<ColorGradientStop>
Remarks
Value semantics. ColorGradientStop is a
readonly struct, providing zero-allocation, stack-allocated value semantics.
Because the struct is readonly, all fields are guaranteed not to change
after construction.
Ordering. Stops are ordered by Offset via IComparable<T>. The parent ColorGradient sorts stops by offset at construction time.
Per-stop interpolation. Each stop can optionally override the gradient's global interpolation behavior via Interpolation. When set to None (default), the gradient's global interpolation is used.
Midpoint. The Midpoint value shifts the interpolation balance point between this stop and its successor. A value of 0.5 (default) produces standard interpolation. Lower values shift the blend toward this stop, higher values toward the next.
Validation. The constructor rejects offsets outside the [0, 1] range with an immediate ArgumentOutOfRangeException (fail-fast).
Constructors
ColorGradientStop(float, Color)
Creates a new gradient stop at the specified offset with a float-precision color.
Declaration
public ColorGradientStop(float offset, Color color)
Parameters
| Type | Name | Description |
|---|---|---|
| float | offset | Normalized position along the gradient, must be in [0, 1]. |
| Color | color | The RGBA color value at this stop. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
ColorGradientStop(float, Color, ColorGradientStopInterpolation, float, bool, ColorStopBlendMode)
Creates a new gradient stop with all fields specified, including per-stop interpolation override and midpoint.
Declaration
public ColorGradientStop(float offset, Color color, ColorGradientStopInterpolation interpolation, float midpoint = 0.5, bool isMuted = false, ColorStopBlendMode blendMode = ColorStopBlendMode.Normal)
Parameters
| Type | Name | Description |
|---|---|---|
| float | offset | Normalized position along the gradient, must be in [0, 1]. |
| Color | color | The RGBA color value at this stop. |
| ColorGradientStopInterpolation | interpolation | Per-stop interpolation override. Use None to inherit the gradient's global interpolation. |
| float | midpoint | The interpolation midpoint between this stop and the next, in the range (0, 1). Defaults to DEFAULT_MIDPOINT. |
| bool | isMuted | |
| ColorStopBlendMode | blendMode |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
ColorGradientStop(float, Color32)
Creates a new gradient stop at the specified offset with a byte-precision color. The UnityEngine.Color32 is converted to UnityEngine.Color internally via Unity's implicit conversion.
Declaration
public ColorGradientStop(float offset, Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| float | offset | Normalized position along the gradient, must be in [0, 1]. |
| Color32 | color | The RGBA color value at this stop in byte precision. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown if |
Fields
DEFAULT_MIDPOINT
The default midpoint value (centered, no shift).
Declaration
public const float DEFAULT_MIDPOINT = 0.5
Field Value
| Type | Description |
|---|---|
| float |
Properties
BlendMode
The per-segment color blend operator applied between this stop and the next. Normal (default) uses straight-line interpolation in the gradient's color space; other modes (Multiply, Screen, Add) operate in linear-light to combine the two endpoint colors.
Declaration
public ColorStopBlendMode BlendMode { get; }
Property Value
| Type | Description |
|---|---|
| ColorStopBlendMode |
Color
The RGBA color value at this stop, in float precision (0.0-1.0 per component).
Declaration
public Color Color { get; }
Property Value
| Type | Description |
|---|---|
| Color |
Color32
The RGBA color value in byte precision (0-255 per component). Computed on each access via Unity's implicit conversion.
Declaration
public Color32 Color32 { get; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Interpolation
The per-stop interpolation override for the transition between this stop and its successor. When set to None (default), the gradient's global interpolation behavior is used.
Declaration
public ColorGradientStopInterpolation Interpolation { get; }
Property Value
| Type | Description |
|---|---|
| ColorGradientStopInterpolation |
IsMuted
When true, this stop is excluded from gradient evaluation as if it
wasn't there. Editing/rendering surfaces still see the stop (so the user
can re-activate it later), but Evaluate(float) and any
interpolation skip over it. Used by the gradient editor's Reduction slider
to non-destructively collapse runs of near-identical adjacent stops.
Declaration
public bool IsMuted { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Midpoint
The interpolation midpoint between this stop and its successor, in the range (0, 1). Defaults to DEFAULT_MIDPOINT (0.5). Shifting the midpoint changes where the 50% blend point falls in the transition.
Declaration
public float Midpoint { get; }
Property Value
| Type | Description |
|---|---|
| float |
Offset
The normalized position of this stop along the gradient, in the range [0, 1]. A value of 0 represents the start and 1 represents the end.
Declaration
public float Offset { get; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
CompareTo(ColorGradientStop)
Compares this stop with another by Offset for sorting.
Declaration
public int CompareTo(ColorGradientStop other)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorGradientStop | other | The stop to compare with. |
Returns
| Type | Description |
|---|---|
| int | A negative value if this stop's offset is less than |
Equals(ColorGradientStop)
Determines whether this stop is equal to another. Two stops are equal if their offsets match (within float tolerance) and all four RGBA color components are identical.
Declaration
public bool Equals(ColorGradientStop other)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorGradientStop | other | The stop to compare with. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
ToString()
Returns a human-readable string of this stop in the format
"0.50 (#FF0000FF)".
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
Operators
operator ==(ColorGradientStop, ColorGradientStop)
Equality operator comparing offset and color.
Declaration
public static bool operator ==(ColorGradientStop left, ColorGradientStop right)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorGradientStop | left | |
| ColorGradientStop | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(ColorGradientStop, ColorGradientStop)
Inequality operator.
Declaration
public static bool operator !=(ColorGradientStop left, ColorGradientStop right)
Parameters
| Type | Name | Description |
|---|---|---|
| ColorGradientStop | left | |
| ColorGradientStop | right |
Returns
| Type | Description |
|---|---|
| bool |