halli - v1.0.0 / Exports / Halli
• new Halli()
Initialize object with a default 10 color array fading from White to Red and with a Tri-Color array from Green to Yellow to Red gradient with 10 steps between each source color.
• colors: string
[]
• triColors: string
[]
▸ genHexArray(hc1
, hc2
, steps
): string
[]
Select n=steps colors between color 1 (hc1) and color 2 (hc2) and populate a return array.
Name | Type | Description |
---|---|---|
hc1 |
string | number |
hexadecimal number representing color |
hc2 |
string | number |
hexadecimal number representing color |
steps |
number |
the number of colors to generate between two colors |
string
[]
array of string hex color codes
▸ genMultiHexArray(input
, steps
): string
[]
genMultiHexArray will take an input array of any number of hex colors and the number of steps to create a smooth gradient fade between the colors in sequence.
Example: input = [0x00FF00, 0xFFFF00, 0xFF0000] with steps = 10 will produce a Green to Yellow to Red gradient with 10 steps between each source color. Total of 23 color codes.
Name | Type | Description |
---|---|---|
input |
string [] | number [] |
array of hexadecimal numbers representing colors |
steps |
number |
the number of colors to generate between two colors |
string
[]
array of string hex color codes
▸ pickHex(hc1
, hc2
, ratio
): string
Select a color between color 1 (hc1) and color 2 (hc2) based on an input ratio that denotes the point in the gradient color should be selected from.
Name | Type | Description |
---|---|---|
hc1 |
string | number |
hexadecimal number representing color |
hc2 |
string | number |
hexadecimal number representing color |
ratio |
number |
the point in the gradient color to be selected |
string
IHexColorString color code in string form
▸ Static
convertToColorString(hex
): string
Function will return a ‘#000000’ string set to the appropriate values.
Name | Type | Description |
---|---|---|
hex |
number |
hexadecimal representation of a color |
string
#000000
▸ Static
Protected
convertToNumber(input
): number
Convert IHexColorNumber or IHexColorString to IHexColorNumber
Name | Type | Description |
---|---|---|
input |
string | number |
convert a hex code string to a number |
number
Number
▸ Static
Private
frontPad(hexStr
): string
Useful for checking front padding of a hex color code
Name | Type | Description |
---|---|---|
hexStr |
string |
string representation of hex color code |
string
0 front padded hex color code
▸ Static
Private
getRGBComponents(input
): IRGB
Break down hex value into RGB components
Name | Type | Description |
---|---|---|
input |
string | number |
hexadecimal IHexColorNumber or IHexColorString representing color |
R, G, B codes
▸ Static
hexToRGBA(hex
): IRGB
Function will return an object with {r,g,b,a} set to appropriate values.
Name | Type | Description |
---|---|---|
hex |
string |
string representation of a color |
R, G, B, A codes
▸ Static
hexToRGBAstr(hex
): `rgba(${number}, ${number}, ${number}, ${number})`
Function will return a ‘rgba( r,g,b,a )’ string set to the appropriate values.
Name | Type | Description |
---|---|---|
hex |
string |
string representation of a color |
`rgba(${number}, ${number}, ${number}, ${number})`
rgba(r, g, b, a)