Converts formats of colors
function
color
outputFormat?: 'number' | 'hex' | 'ansi' | 'ansi-16' | 'ansi-16m' | 'ansi-256' | 'css' | 'HEX' | 'hsl' | 'lab' | 'rgb' | 'rgba'
): null | string;
@param input
A value that could possibly be a color
@param outputFormat
An optional output format
outputFormat: '[rgb]'
): null | [number, number, number];
Convert any color input to rgb
@param input
Any color input
@param outputFormat
Specify [rgb]
to output as an array with r
, g
, and b
properties
outputFormat: '[rgba]'
): null | [number, number, number, number];
Convert any color input to rgba
@param input
Any color input
@param outputFormat
Specify [rgba]
to output as an array with r
, g
, b
, and a
properties
outputFormat: '{rgb}'
): null | { b: number; g: number; r: number };
Convert any color input to a number
@param input
Any color input
@param outputFormat
Specify {rgb}
to output as an object with r
, g
, and b
properties
outputFormat: '{rgba}'
): null | { a: number; b: number; g: number; r: number };
Convert any color input to rgba
@param input
Any color input
@param outputFormat
Specify {rgba} to output as an object with r
, g
, b
, and a
properties
outputFormat: 'number'
): null | number;
Convert any color input to a number
@param input
Any color input
@param outputFormat
Specify number
to output as a number
Referenced types
type ColorInput = { a: number; b: number; g: number; r: number } | [number, number, number] | [number, number, number, number] | Uint8Array | Uint8ClampedArray | Float32Array | Float64Array | string | number | { toString(): string }
Valid inputs for color