halli

halli - v1.0.0 / Exports / Halli

Class: Halli

Table of contents

Constructors

Properties

Methods

Constructors

constructor

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.

Defined in

halli.ts:34

Properties

colors

colors: string[]

Defined in

halli.ts:26


triColors

triColors: string[]

Defined in

halli.ts:27

Methods

genHexArray

genHexArray(hc1, hc2, steps): string[]

Select n=steps colors between color 1 (hc1) and color 2 (hc2) and populate a return array.

Parameters

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

Returns

string[]

array of string hex color codes

Defined in

halli.ts:135


genMultiHexArray

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.

Parameters

Name Type Description
input string[] | number[] array of hexadecimal numbers representing colors
steps number the number of colors to generate between two colors

Returns

string[]

array of string hex color codes

Defined in

halli.ts:191


pickHex

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.

Parameters

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

Returns

string

IHexColorString color code in string form

Defined in

halli.ts:100


convertToColorString

Static convertToColorString(hex): string

Function will return a ‘#000000’ string set to the appropriate values.

Parameters

Name Type Description
hex number hexadecimal representation of a color

Returns

string

#000000

Defined in

halli.ts:281


convertToNumber

Static Protected convertToNumber(input): number

Convert IHexColorNumber or IHexColorString to IHexColorNumber

Parameters

Name Type Description
input string | number convert a hex code string to a number

Returns

number

Number

Defined in

halli.ts:65


frontPad

Static Private frontPad(hexStr): string

Useful for checking front padding of a hex color code

Parameters

Name Type Description
hexStr string string representation of hex color code

Returns

string

0 front padded hex color code

Defined in

halli.ts:83


getRGBComponents

Static Private getRGBComponents(input): IRGB

Break down hex value into RGB components

Parameters

Name Type Description
input string | number hexadecimal IHexColorNumber or IHexColorString representing color

Returns

IRGB

R, G, B codes

Defined in

halli.ts:48


hexToRGBA

Static hexToRGBA(hex): IRGB

Function will return an object with {r,g,b,a} set to appropriate values.

Parameters

Name Type Description
hex string string representation of a color

Returns

IRGB

R, G, B, A codes

Defined in

halli.ts:245


hexToRGBAstr

Static hexToRGBAstr(hex): `rgba(${number}, ${number}, ${number}, ${number})`

Function will return a ‘rgba( r,g,b,a )’ string set to the appropriate values.

Parameters

Name Type Description
hex string string representation of a color

Returns

`rgba(${number}, ${number}, ${number}, ${number})`

rgba(r, g, b, a)

Defined in

halli.ts:269