Class ColorGradient
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Helper for creating and interpolating smooth color gradients. Supports predefined gradients (cool, warm, spectrum, grayscale) and custom gradients.
public class ColorGradient
- Inheritance
-
ColorGradient
- Inherited Members
Fields
Predefined
Predefined gradients available for use.
public static readonly Dictionary<string, ColorGradient> Predefined
Field Value
Methods
FromColors(params Color[])
Creates a gradient from a sequence of colors.
public static ColorGradient FromColors(params Color[] colors)
Parameters
colorsColor[]Colors to use as gradient stops (minimum 2 required)
Returns
- ColorGradient
New ColorGradient instance
Interpolate(double)
Gets a color at a specific position in the gradient.
public Color Interpolate(double normalizedValue)
Parameters
normalizedValuedoublePosition in gradient (0.0 = first color, 1.0 = last color)
Returns
- Color
Interpolated color at the specified position
Parse(string?)
Parses a gradient specification string. Supports predefined names (cool, warm, spectrum, grayscale), arrow notation (blue→cyan→green), and :reverse suffix.
public static ColorGradient? Parse(string? spec)
Parameters
specstringGradient specification (e.g., "cool", "blue→cyan", "warm:reverse")
Returns
- ColorGradient
Parsed ColorGradient, or null if parsing fails
Reverse()
Returns a new gradient with reversed color order.
public ColorGradient Reverse()
Returns
- ColorGradient
New ColorGradient with colors in reverse order