Color
Color manipulation utilities for converting between different color formats.
Installation
typescript
import * as color from '@beerush/utils/global/color'
// or
import { hexToRgb } from '@beerush/utils/global/color'Functions
cmykToRgb
Convert CMYK to RGB.
typescript
cmykToRgb(cyan: Cyan, magenta: Magenta, yellow: Yellow, black: Black): RGBhexToRgb
Convert HEX to RGB.
typescript
hexToRgb(hex: HEXColor): RGBhslToRgb
Convert HSL to RGB.
typescript
hslToRgb(hue: Hue, saturation: Saturation, lightness: Lightness): RGBhslaToRgba
Convert HSLA to RGBA.
typescript
hslaToRgba(hue: Hue, saturation: Saturation, lightness: Lightness, alpha: Alpha): RGBArgbToHex
Convert RGB to HEX.
typescript
rgbToHex(red: Red, green: Green, blue: Blue): HEXColorrgbToHsl
Convert RGB to HSL.
typescript
rgbToHsl(red: Red, green: Green, blue: Blue): HSLrgbaToHsla
Convert RGBA to HSLA.
typescript
rgbaToHsla(red: Red, green: Green, blue: Blue, alpha: Alpha): HSLAtoHex
Convert any color format to HEX.
typescript
toHex(color: string): HEXColortoRgb
Convert any color format to RGB string.
typescript
toRgb(color: string): RGBStringtoRgba
Convert any color format to RGBA string.
typescript
toRgba(color: string, alpha?: number): RGBAStringTypes
Red- Range from 0 to 255Green- Range from 0 to 255Blue- Range from 0 to 255Alpha- Range from 0 to 100Hue- Range from 0 to 360Saturation- Range from 0 to 100Lightness- Range from 0 to 100HEXColor- Hex color string formatRGB- RGB tuple formatRGBA- RGBA tuple formatHSL- HSL tuple formatHSLA- HSLA tuple formatCMYK- CMYK tuple format