circleci Custom npmV min install githubLastCommit

Note: if you want a reliable library use something like color instead.

Docs

ColorConverters

RGBToHSV
/**
 * Takes an `RGBColor` and converts it to `HSVColor`
 */
function RGBToHSV(color: RGBColor, is255?: boolean): HSVColor;
HSVToRGB
/**
 * Takes an `HSVColor` and converts it to `RGBColor`
 */
function HSVToRGB(hsv: HSVColor, is100?: boolean): RGBColor;
StringToRGB
/**
 * Takes an `StringColor` and converts it to `RGBColor`,
 * If input string is invalid `null` will be returned.
 */
function StringToRGB(input: string, return255?: boolean, alpha255?: boolean): RGBColor | null | undefined;
StringToHVS
/**
 * Takes an `StringColor` and converts it to `HSVColor`,
 * If input string is invalid `null` will be returned.
 */
function StringToHVS(input: string, return255?: boolean, alpha255?: boolean): HSVColor | null | undefined;
HSVToHEX
/**
 * Takes an `HSVColor` and converts it to `String` (HEX Format)
 */
function HSVToHEX(hsv: HSVColor, options?: {
    type?: GetColorTypeHex;
    isLong?: boolean;
}
RGBToHEX
/**
 * Takes an `RGBColor` and converts it to `String` (HEX Format)
 */
function RGBToHEX(color: RGBColor, type?: GetColorTypeHex): string;

ColorTypes

RGBColor
/**
 * Represents a color in the rgb(a) format.
 *
 *
 * Range `[0 - 1]`
 */
class RGBColor {
    /**
     * Range [0-1]
     */
    r: number;
    /**
     * Range [0-1]
     */
    g: number;
    /**
     * Range [0-1]
     */
    b: number;
    /**
     * Range [0-1]
     */
    a: number;
    constructor(r: number, g: number, b: number, a?: number);
}
HSVColor
/**
 * Represents a color in the hsv(a) format.
 *
 *
 * Range `[h 0 - 360, v/s/a 0 - 1]`
 */
class HSVColor {
    /**
     * Range [0-360]
     */
    h: number;
    /**
     * Range [0-100]
     */
    s: number;
    /**
     * Range [0-100]
     */
    v: number;
    /**
     * Range [0-1]
     */
    a: number;
    constructor(h: number, s: number, v: number, a?: number);
}
StringColor
/**
 * Represents a color in a string format.
 * Valid strings are `#000 | #0000 | #000000 | #00000000`
 * Or `rgb(0, 0, 0, 0) | rgba(0, 0, 0, 0, 0)` Range [rgb 0-255, a: 0-1]
 *
 */
class StringColor {
    color: string;
    constructor(color: string);
}

HandleGet

HandleGetHex
function HandleGetHex(type: GetColorType, color: RGBColor, options?: GetColorOptions): string;

HandleSet

ConvertString
function ConvertString(input: string, return255?: boolean, alpha255?: boolean): RGBColor;
HandleConvertHexString
/**
 * **assumes that the input is valid**
 */
function HandleConvertHexString(text: string, return255?: boolean, alpha255?: boolean): RGBColor;

index

interfaces

GetColorTypeHex
type GetColorTypeHex = 'hex' | 'hex-short' | 'hex-without-alpha' | 'hex-without-alpha-short';
GetColorType
type GetColorType = 'rgb' | GetColorTypeHex | 'rgba' | 'object' | 'hsv';
GetColorOptions
interface GetColorOptions {
    /**
     * if true `#fff` will be output as `#FFF`
     */
    UpperCaseHex: boolean;
}

regex

isValidHex
function isValidHex(text: string): boolean;
isValidRGB
function isValidRGB(text: string): boolean;

utils

GetReadableTextColor
function GetReadableTextColor(color: RGBColor | HSVColor | StringColor | string): RGBColor | HSVColor | "#000" | "#fff";
ShiftHue
/**
 * Shifts the hue of the `HSVColor` by the Value
 */
function ShiftHue(hsv: HSVColor, value: number): HSVColor;
convertCssColorToHex
/**Returns the hex value of the color string or the input string */
function convertCssColorToHex(color: string): string;

validators

isValidStringColor
function isValidStringColor(input: string): string;

Generated with suf-cli

License

Copyright (c) 2020 Leonard Grosoli Licensed under the MIT license.