Class Color
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Parameters
- r: number
Red component premultiplied by
alpha0..1 - g: number
Green component premultiplied by
alpha0..1 - b: number
Blue component premultiplied by
alpha0..1 Optionalalpha: numberAlpha component 0..1
Optionalpremultiplied: booleanWhether the
r,gandbvalues have already been multiplied by alpha. Iftruenothing happens iffalsethen they will be multiplied automatically.
Returns Color
- r: number
Properties
Readonlya
Readonlyb
Readonlyg
Readonlyr
Staticblack
Staticred
Statictransparent
Staticwhite
Accessors
hcl
Used in color interpolation.
Returns HCLColor
Gien color, with reversed alpha blending, in HCL color space.
lab
Used in color interpolation.
Returns LABColor
Gien color, with reversed alpha blending, in LAB color space.
rgb
Used in color interpolation and by 'to-rgba' expression.
Returns RGBColor
Gien color, with reversed alpha blending, in sRGB color space.
Methods
toString
Used by 'to-string' expression.
Returns string
Serialized color in format
rgba(r,g,b,a)where r,g,b are numbers within 0..255 and alpha is number within 1..0
Staticinterpolate
Parameters
- from: Color
- to: Color
- t: number
OptionalspaceKey: InterpolationColorSpace
Returns Color
Staticparse
Parses CSS color strings and converts colors to sRGB color space if needed. Officially supported color formats:
- keyword, e.g. 'aquamarine' or 'steelblue'
- hex (with 3, 4, 6 or 8 digits), e.g. '#f0f' or '#e9bebea9'
- rgb and rgba, e.g. 'rgb(0,240,120)' or 'rgba(0%,94%,47%,0.1)' or 'rgb(0 240 120 / .3)'
- hsl and hsla, e.g. 'hsl(0,0%,83%)' or 'hsla(0,0%,83%,.5)' or 'hsl(0 0% 83% / 20%)'
Parameters
- input: string | Color | null | undefined
CSS color string to parse.
Returns Color | undefined
A
Colorinstance, orundefinedif the input is not a valid color string.
Color representation used by WebGL. Defined in sRGB color space and pre-blended with alpha.
Private