RgbaColor
Interface representing a color in RGBA format.number
Red component (0-255)
number
Green component (0-255)
number
Blue component (0-255)
number
Alpha component (0-1)
parseColor
Parses a color string into an RGBA object.string
required
Color string in hex, RGB/RGBA, or HSL/HSLA format
RgbaColor
Parsed color as an RGBA object
Supported formats
- Hex:
#RGB,#RGBA,#RRGGBB,#RRGGBBAA - RGB/RGBA:
rgb(r, g, b),rgba(r, g, b, a) - HSL/HSLA:
hsl(h, s%, l%),hsla(h, s%, l%, a)
Example
Errors
ThrowsHeliosError with code INVALID_COLOR_FORMAT if the color string is not in a supported format.
interpolateColors
Interpolates between colors based on an input value.number
required
The value to interpolate
number[]
required
Array of input values (must be strictly monotonically increasing). Minimum 2 elements.
string[]
required
Array of output color strings (must match length of inputRange). Colors can be in any supported format.
InterpolateOptions
Configuration for extrapolation and easing
string
Interpolated color as an RGBA string
Options
'extend' | 'clamp' | 'identity'
Behavior when input is less than the first inputRange value. Default:
'extend''extend' | 'clamp' | 'identity'
Behavior when input is greater than the last inputRange value. Default:
'extend'(t: number) => number
Easing function to apply to the interpolation ratio
Example
Errors
ThrowsHeliosError with:
INVALID_INPUT_RANGEif inputRange and outputRange lengths don’t match or have fewer than 2 elementsUNSORTED_INPUT_RANGEif inputRange is not strictly monotonically increasingINVALID_COLOR_FORMATif any color in outputRange cannot be parsed