This set of packages works with different types of color aggregations. Each aggregation is needed to work specifically with TypeScript.
ColorFormats
This interface can contain every format and can select a specific color format by its format name.
Type
Each value should be as its interface or type specifies, read about format types to know more.
interface ColorFormats {
cmyk?: Cmyk
hex?: Hex
hsl?: Hsl
hsv?: Hsv
lab?: Lab
rgb?: Rgb
xyz?: Xyz
}
// Examples
const colors: ColorFormats = {
hex: '#42D37A',
rgb: { r: 66, g: 211, b: 122 }
}
const otherColors: ColorFormats = {
hsl: { h: 143, s: 62, l: 54 },
hsv: { h: 143, s: 69, v: 83 }
}
BaseColor
This type determines whether a value is of type Cmyk, Hex, Hsl, Hsv, Rgb, Lab or XYZ.
Type
Each value should be as its interface or type specifies, read about format types to know more.
type BaseColor = Cmyk | Hex | Hsl | Hsv | Rgb;
// Examples
const color: BaseColor = '#42D37A'
const otherColor: BaseColor = { r: 66, g: 211, b: 122 };
Color
This type determines whether a value is of type Cmyk, Hex, Hsl, Hsv, Lab, Rgb, or Xyz. This type is used in this set of packages as a return type cause it contains imprecise types like Lab and Xyz.
Type
Each value should be as its interface or type specifies, read about format types to know more.
type Color = Cmyk | Hex | Hsl | Hsv | Lab | Rgb | Xyz
// Examples
const color: Color = '#42D37A'
const rgbColor: Color = { r: 66, g: 211, b: 122 }
const labColor: Color = { l: 76, a: -58, b: 33 }