Converts formats of colors
Symbol
color
function color(input: ColorInput, outputFormat?: 'number' | 'ansi' | 'ansi-16' | 'ansi-16m' | 'ansi-256' | 'css' | 'hex' | 'HEX' | 'hsl' | 'lab' | 'rgb' | 'rgba'): null | string
@param input
A value that could possibly be a color
@param outputFormat
An optional output format
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
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
function color(input: ColorInput, 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
function color(input: ColorInput, 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
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