UNPKG

seed-color

Version:

Generate random colors from a seed

162 lines (161 loc) 3.03 kB
/** * Color */ export default class Color { /** * Red */ r: number; /** * Green */ g: number; /** * Blue */ b: number; /** * Alpha */ a: number; /** * RGB Array: [r, g, b] */ rgb: number[]; /** * Hex to RGB */ static parseHex(hex: string): RGB; /** * Analyze string */ static parseString(x: string): RGB; /** * Convert RGB to HSV */ static rgbToHsv(color: string | Color | RGB | number[]): HSV; static rgbToHsv(r: number, g: number, b: number): HSV; /** * Convert RGB to HSL */ static rgbToHsl(color: string | Color | RGB | number[]): HSL; static rgbToHsl(r: number, g: number, b: number): HSL; /** * Convert HSV to RGB */ static hsvToRgb(hsv: HSV): RGB; static hsvToRgb(h: number, s: number, v: number): RGB; /** * Convert HSL to RGB */ static hslToRgb(hsl: HSL): RGB; static hslToRgb(h: number, s: number, l: number): RGB; constructor(color: string | Color | RGB | HSV | HSL); constructor(r: number, g: number, b: number); /** * Get an RGB object that represent this color */ toRGB(): RGB; /** * Set the color using the RGB */ setRGB(rgb: RGB): Color; /** * Get HSV object */ toHSV(): HSV; /** * Set the color using the HSV */ setHSV(hsv: HSV): void; setHSV(h: number, s: number, v: number): void; /** * Get HSL object */ toHSL(): HSL; /** * Set the color using the HSL */ setHSL(hsl: HSL): void; setHSL(h: number, s: number, l: number): void; /** * Get color code */ toHex(withNumberSign?: boolean): string; /** * Get luminance of this color */ luminance(rWeight?: number, gWeight?: number, bWeight?: number): number; contrast(threshold?: number, dark?: Color, light?: Color): Color; /** * Invert this color */ invert(): Color; /** * Clone this instance */ clone(): Color; } /** * "Red Green Blue" color space */ export declare type RGB = { /** * Red */ r: number; /** * Green */ g: number; /** * Blue */ b: number; /** * Alpha */ a?: number; }; /** * "Hue Saturation Brightness" color space */ export declare type HSV = { /** * Hue */ h: number; /** * Saturation */ s: number; /** * Brightness */ v: number; /** * Alpha */ a?: number; }; /** * "Hue Saturation Luminance" color space */ export declare type HSL = { /** * Hue */ h: number; /** * Saturation */ s: number; /** * Luminance */ l: number; /** * Alpha */ a?: number; };