soon-colors
v0.0.3
Published
A collection of utils for colors
Readme
soon-colors
A collection of utils for colors
API
//types
export type RgbColor = [red: number, green: number, blue: number];
export type HslColor = [hue: number, saturation: number, lightness: number];
export type HwbColor = [hue: number, whiteness: number, blackness: number];
export type OklabColor = [lightness: number, a: number, b: number];
export type OklchColor = [lightness: number, chroma: number, hue: number];
// RGB <-> HSL
export declare function rgb2hsl(color: RgbColor): HslColor;
export declare function hsl2rgb(color: HslColor): RgbColor;
// RGB <-> HWB
export declare function rgb2hwb(color: RgbColor): HwbColor;
export declare function hwb2rgb(color: HwbColor): RgbColor;
// HEX <-> RGB
export declare function hex2rgb(hex: string): [rgbColor: RgbColor, opacity?: number];
export declare function rgb2hex(color: RgbColor, opacity?: number): string;
// RGB <-> OKLAB
export declare function rgb2oklab(color: RgbColor): OklabColor;
export declare function oklab2rgb(color: OklabColor): RgbColor;
// OKLAB <-> OKLCH
export declare function oklab2oklch(color: OklabColor): OklchColor;
export declare function oklch2oklab(color: OklchColor): OklabColor;
// RGB <-> OKLCH
export declare function rgb2oklch(color: RgbColor): OklchColor;
export declare function oklch2rgb(color: OklchColor): RgbColor;
// color-mix
/**
* It works like function css color-mix with mode 'srgb'
*
* @param color1
* @param color2
* @param color1Percentage range [0-1], default: 0.5
* @param color2Percentage range [0-1], default: 1 - color1Percentage
* @returns [ mixedRgbColor , opacity ]
*/
export declare function mixRgb(
color1: RgbColor,
color2: RgbColor,
color1Percentage?: number,
color2Percentage?: number
): [mixedColor: RgbColor, opacity: number];