@tempots/color

tempotempotscolorslibrarytypescriptcmykhslhslahsluvhsvlablchluvmathrgbrgbasrgbxyz
Colors library for TypeScript.

The @tempots/color library provides a set of immutable color classes and functions to convert between color spaces.

color package

Classes

Class

Description

CMYK

Represents a color in the CMYK color model.

HSL

Represents a color in the HSL (Hue, Saturation, Lightness) color model.

HSLA

Represents the HSLA color model.

HSLuv

Represents a color in the HSLuv color space.

HSV

Represents a color in the HSV (Hue, Saturation, Value) color model.

LAB

Represents a color in the CIELAB color space.

LCH

Represents a color in the LCH color space.

LUV

Represents a color in the LUV color space.

RGB

Represents a color in the RGB color model.

RGBA

Represents a color in the RGBA format.

SRGB

Represents a color in the sRGB color space.

XYZ

Represents a color in the XYZ color space.

Functions

Function

Description

clamp(value, min, max)

clamp restricts a value within the specified range.

clampInt(value, min, max)

clampInt restricts a value within the specified range and returns an integer.

cmyk2hsl(cmyk)

Converts a CMYK color to an HSL color.

cmyk2hsluv(cmyk, whiteReference)

Converts a CMYK color to an HSLuv color.

cmyk2hsv(cmyk)

Converts a CMYK color to an HSV color.

cmyk2lab(cmyk, whiteReference)

Converts a CMYK color to LAB color using a specified white reference.

cmyk2lch(cmyk, whiteReference)

Converts a CMYK color to LCH color.

cmyk2luv(cmyk, whiteReference)

Converts a CMYK color to LUV color space.

cmyk2rgb(cmyk)

Converts a CMYK color to an RGB color.

cmyk2srgb(cmyk)

Converts a CMYK color to an sRGB color.

cmyk2xyz(cmyk)

Converts a CMYK color to XYZ color space.

distanceFromOriginAngle(slope, intercept, angle)

lerp performs a linear interpolation between two values.

hsl2cmyk(hsl)

Converts an HSL color to CMYK color.

hsl2hsluv(hsl, whiteReference)

Converts an HSL color to an HSLuv color.

hsl2hsv(hsl)

Converts an HSL color to HSV color.

hsl2lab(hsl, whiteReference)

Converts an HSL color to LAB color.

hsl2lch(hsl, whiteReference)

Converts an HSL color to LCH color.

hsl2luv(hsl, whiteReference)

Converts an HSL color value to LUV color space.

hsl2rgb(hsl)

Converts an HSL color value to an RGB color value.

hsl2srgb(hsl)

Converts an HSL color value to an SRGB color value.

hsl2xyz(hsl)

Converts an HSL color to XYZ color space.

hsluv2cmyk(hsluv, whiteReference)

Converts an HSLuv color to CMYK color.

hsluv2hsl(hsluv, whiteReference)

Converts an HSLuv color to an HSL color.

hsluv2hsv(hsluv, whiteReference)

Converts an HSLuv color to an HSV color.

hsluv2lab(hsluv)

Converts an HSLuv color to LAB color.

hsluv2lch(hsluv)

Converts an HSLuv color to LCH color.

hsluv2luv(hsluv, whiteReference)

Converts an HSLuv color to LUV color.

hsluv2rgb(hsluv, whiteReference)

Converts an HSLuv color value to an RGB color value.

hsluv2srgb(hsluv, whiteReference)

Converts an HSLuv color value to an sRGB color value.

hsluv2xyz(hsluv, whiteReference)

Converts an HSLuv color to XYZ color space.

hsv2cmyk(hsv)

Converts an HSV color to CMYK color.

hsv2hsl(hsv)

Converts an HSV color value to HSL.

hsv2hsluv(hsv, whiteReference)

Converts an HSV color value to an HSLuv color value.

hsv2lab(hsv, whiteReference)

Converts an HSV color value to a LAB color value.

hsv2lch(hsv, whiteReference)

Converts an HSV color value to an LCH color value.

hsv2luv(hsv, whiteReference)

Converts an HSV color value to an LUV color value.

hsv2rgb(hsv)

Converts an HSV color value to an RGB color value.

hsv2srgb(hsv)

Converts an HSV color value to an SRGB color value.

hsv2xyz(hsv)

Converts an HSV color to XYZ color space.

lab2cmyk(lab, whiteReference)

Converts a color from LAB color space to CMYK color space.

lab2hsl(lab, whiteReference)

Converts a color from LAB color space to HSL color space.

lab2hsluv(lab)

Converts a LAB color to HSLuv color.

lab2hsv(lab, whiteReference)

Converts a color from LAB color space to HSV color space.

lab2lch(lab)

Converts a LAB color to LCH color.

lab2luv(lab, whiteReference)

Converts a color from LAB color space to LUV color space.

lab2rgb(lab, whiteReference)

Converts a color from LAB color space to RGB color space.

lab2srgb(lab, whiteReference)

Converts a color from LAB color space to SRGB color space.

lab2xyz(lab, whiteReference)

Converts a color from LAB color space to XYZ color space.

lch2cmyk(lch, whiteReference)

Converts an LCH color to CMYK color.

lch2hsl(lch, whiteReference)

Converts a color in LCH color space to HSL color space.

lch2hsluv(lch)

Converts a color in the LCH color space to the HSLuv color space.

lch2hsv(lch, whiteReference)

Converts a color in the LCH color space to the HSV color space.

lch2lab(lch)

Converts a color in LCH color space to LAB color space.

lch2luv(lch, whiteReference)

Converts a color from LCH (Lightness, Chroma, Hue) to LUV (Lightness, U, V) color space.

lch2rgb(lch, whiteReference)

Converts an LCH color value to an RGB color value.

lch2srgb(lch, whiteReference)

Converts an LCH color value to an sRGB color value.

lch2xyz(lch, whiteReference)

Converts a color in the LCH color space to the XYZ color space.

luv2cmyk(luv, whiteReference)

Converts an LUV color to CMYK color.

luv2hsl(luv, whiteReference)

Converts a color from LUV color space to HSL color space.

luv2hsluv(luv, whiteReference)

Converts a color from LUV color space to HSLuv color space.

luv2hsv(luv, whiteReference)

Converts a color from LUV color space to HSV color space.

luv2lab(luv, whiteReference)

Converts a color in LUV color space to LAB color space.

luv2lch(luv, whiteReference)

Converts a color in LUV color space to LCH color space.

luv2rgb(luv, whiteReference)

Converts a color from LUV color space to RGB color space.

luv2srgb(luv, whiteReference)

Converts a color from LUV color space to SRGB color space.

luv2xyz(luv, whiteReference)

Converts a color in LUV color space to XYZ color space.

nearEquals(a, b, tollerance)

number numbers can sometime introduce tiny errors even for simple operations. nearEquals compares two floats using a tiny tollerance (last optional argument). By default it is defined as EPSILON.

rgb2cmyk(rgb)

Converts an RGB color to CMYK color representation.

rgb2hsl(rgb)

Converts an RGB color to HSL color.

rgb2hsluv(rgb, whiteReference)

Converts an RGB color to HSLuv color.

rgb2hsv(rgb)

Converts an RGB color value to its corresponding HSV representation.

rgb2lab(rgb, whiteReference)

Converts an RGB color to the LAB color space.

rgb2lch(rgb, whiteReference)

Converts an RGB color to LCH color.

rgb2luv(rgb, whiteReference)

Converts an RGB color to LUV color space.

rgb2srgb(rgb)

Converts an RGB color to an sRGB color.

rgb2xyz(rgb)

Converts an RGB color to XYZ color space.

srgb2cmyk(srgb)

Converts an SRGB color to CMYK color.

srgb2hsl(srgb)

Converts an SRGB color value to HSL color space.

srgb2hsluv(srgb, whiteReference)

Converts an sRGB color value to an HSLuv color value.

srgb2hsv(srgb)

Converts an sRGB color to HSV color space.

srgb2lab(srgb, whiteReference)

Converts an SRGB color to LAB color space.

srgb2lch(srgb, whiteReference)

Converts an sRGB color to LCH color.

srgb2luv(srgb, whiteReference)

Converts an sRGB color to LUV color space.

srgb2rgb(srgb)

Converts an SRGB color to an RGB color.

srgb2xyz(srgb)

Converts an sRGB color to XYZ color space.

xyz2cmyk(xyz)

Converts an XYZ color to CMYK color.

xyz2hsl(xyz)

Converts XYZ color space to HSL color space.

xyz2hsluv(xyz, whiteReference)

Converts XYZ color space to HSLuv color space.

xyz2hsv(xyz)

Converts XYZ color space to HSV color space.

xyz2lab(xyz, whiteReference)

Converts XYZ color space to LAB color space.

xyz2lch(xyz, whiteReference)

Converts XYZ color space to LCH color space.

xyz2luv(xyz, whiteReference)

Converts XYZ color space to LUV color space.

xyz2rgb(xyz)

Converts XYZ color space to RGB color space.

xyz2srgb(xyz)

Converts XYZ color space to SRGB color space.

Variables

Variable

Description

EPSILON

Constant value employed to see if two number values are very close.

WHITE_REFERENCE

Constant value for the white reference.