ColorUtils
Collection of functions that provide basic operations on colors represented as RGB/HSL value (given in the form of array of numbers) or hex code (given in the form of string)
Static Method Summary
Static Public Methods | ||
public static |
decimalRound(number: number, precision: number): number Decimal rounding with a given precision |
|
public static |
Converts a hex color code string to an HSL representation |
|
public static |
Converts a hex color code string to a decimal representation |
|
public static |
Converts HSL value to hex code |
|
public static |
Converts HSL value to RGB value |
|
public static |
isSameHexColor(hexCode1: string, hexCode2: string): boolean Checks if given two hex color codes represent a same color. |
|
public static |
Checks if given two RGB values represent a same color. |
|
public static |
Checks if a given object is a string |
|
public static |
isUpperCase(str: string): boolean Checks if a given string is consists of uppercase letters |
|
public static |
isValidHexCode(code: string): boolean Checks if a given string is a valid representation of RGB color. |
|
public static |
Checks if a given array is a valid representation of HSL color. |
|
public static |
Checks if a given array is a valid representation of RGB color. |
|
public static |
normalizeHexCode(hexString: string, prefix: boolean): string Converts a hex color code to a 6-digit hexadecimal string |
|
public static |
Converts a decimal representation of color to a hex code string |
|
public static |
Converts RGB value to HSL value |
Static Public Methods
public static decimalRound(number: number, precision: number): number source
Decimal rounding with a given precision
public static hexCodeToHsl(hexCode: string): Array<number, number, number> source
Converts a hex color code string to an HSL representation
Params:
Name | Type | Attribute | Description |
hexCode | string | Hex color code such as "#ffff00" |
public static hexCodeToRgb(hexCode: string): Array<number, number, number> source
Converts a hex color code string to a decimal representation
Params:
Name | Type | Attribute | Description |
hexCode | string | Hex color code such as "#ffff00" |
public static hslToHexCode(hsl: Array<number, number, number>): string source
Converts HSL value to hex code
public static hslToRgb(hsl: Array<number, number, number>): Array<number, number, number> source
Converts HSL value to RGB value
public static isSameHexColor(hexCode1: string, hexCode2: string): boolean source
Checks if given two hex color codes represent a same color.
public static isSameRgbColor(rgb1: Array<number, number, number>, rgb2: Array<number, number, number>): boolean source
Checks if given two RGB values represent a same color.
public static isString(str: object): boolean source
Checks if a given object is a string
Params:
Name | Type | Attribute | Description |
str | object | Object to be checked |
public static isUpperCase(str: string): boolean source
Checks if a given string is consists of uppercase letters
Params:
Name | Type | Attribute | Description |
str | string | string to be checked |
public static isValidHexCode(code: string): boolean source
Checks if a given string is a valid representation of RGB color.
Params:
Name | Type | Attribute | Description |
code | string | RGB value in hex code |
public static isValidHsl(hsl: Array<number, number, number>): boolean source
Checks if a given array is a valid representation of HSL color.
public static isValidRgb(rgb: Array<number, number, number>): boolean source
Checks if a given array is a valid representation of RGB color.
public static normalizeHexCode(hexString: string, prefix: boolean): string source
Converts a hex color code to a 6-digit hexadecimal string
public static rgbToHexCode(rgb: Array<number, number, number>): string source
Converts a decimal representation of color to a hex code string