Class ColorRamps
Derives tints, shades, tones, full light-to-dark ramps, and material tone sets from a single base color, interpolating in Oklab so the steps are perceptually even.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public static class ColorRamps
Remarks
A tint blends toward white, a shade blends toward black, and a tone blends toward the base color's own desaturated grey. Blending in Oklab rather than sRGB is what keeps the middle of a ramp from going muddy, which is the usual failure of a naive RGB lerp.
Each generator has an allocating overload that returns a new array and a Span<T> overload that writes into a caller-owned buffer. Use the span form anywhere the result is regenerated often, such as re-deriving a theme's token table when the accent color changes.
Methods
GenerateMaterialTones(Color)
Generates a four-entry material tone set from a base color: shadow, base, highlight, and rim.
Declaration
public static Color[] GenerateMaterialTones(Color baseColor)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
Returns
| Type | Description |
|---|---|
| Color[] | A new four-element array in shadow, base, highlight, rim order. |
Remarks
The four entries shift lightness, scale chroma, and rotate hue by small fixed amounts, which gives a shaded material read rather than a flat lightness ramp. The hue rotates warmer toward the highlight, mimicking how a lit surface behaves.
GenerateMaterialTones(Color, Span<Color>)
Generates a four-entry material tone set into a caller-owned buffer.
Declaration
public static void GenerateMaterialTones(Color baseColor, Span<Color> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| Span<Color> | destination | Receives the shadow, base, highlight, and rim tones. Must hold at least four elements. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
GenerateRamp(Color, int)
Generates a full ramp that runs from near-black through the base color to near-white.
Declaration
public static Color[] GenerateRamp(Color baseColor, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| int | count | The number of ramp entries. Values below 3 are raised to 3. |
Returns
| Type | Description |
|---|---|
| Color[] | A new array running dark to light with the base color in the middle. |
Remarks
The base color is placed at the middle index, so the result reads as a symmetric light-to-dark scale around it. With an even count the middle sits one step below center.
GenerateRamp(Color, Span<Color>)
Generates a full dark-to-light ramp into a caller-owned buffer, placing the base color at the middle index.
Declaration
public static void GenerateRamp(Color baseColor, Span<Color> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| Span<Color> | destination | Receives one ramp entry per element. Spans shorter than three elements are filled by the same rule and simply have less room around the base. |
GenerateShades(Color, int)
Generates a series of shades, blending the base color toward black.
Declaration
public static Color[] GenerateShades(Color baseColor, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| int | count | The number of shades. Values below 2 are raised to 2. |
Returns
| Type | Description |
|---|---|
| Color[] | A new array of shades, starting at the base color and stopping short of black. |
GenerateShades(Color, Span<Color>)
Generates a series of shades into a caller-owned buffer, blending the base color toward black.
Declaration
public static void GenerateShades(Color baseColor, Span<Color> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| Span<Color> | destination | Receives one shade per element. An empty span does nothing. |
GenerateTints(Color, int)
Generates a series of tints, blending the base color toward white.
Declaration
public static Color[] GenerateTints(Color baseColor, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| int | count | The number of tints. Values below 2 are raised to 2. |
Returns
| Type | Description |
|---|---|
| Color[] | A new array of tints, starting at the base color and stopping short of white. |
GenerateTints(Color, Span<Color>)
Generates a series of tints into a caller-owned buffer, blending the base color toward white.
Declaration
public static void GenerateTints(Color baseColor, Span<Color> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| Span<Color> | destination | Receives one tint per element. An empty span does nothing. |
GenerateTones(Color, int)
Generates a series of tones, blending the base color toward the grey that shares its lightness.
Declaration
public static Color[] GenerateTones(Color baseColor, int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| int | count | The number of tones. Values below 2 are raised to 2. |
Returns
| Type | Description |
|---|---|
| Color[] | A new array of tones, starting at the base color. |
Remarks
The target grey is the base color with its Oklch chroma set to zero, so a tone series desaturates without changing perceived brightness.
GenerateTones(Color, Span<Color>)
Generates a series of tones into a caller-owned buffer, blending the base color toward the grey that shares its lightness.
Declaration
public static void GenerateTones(Color baseColor, Span<Color> destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | baseColor | The color to derive from. |
| Span<Color> | destination | Receives one tone per element. An empty span does nothing. |