Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

Type aliases

AnalogousOption

AnalogousOption: { results: number; slices: number }

Type declaration

  • results: number
  • slices: number

BetweenOption

BetweenOption: { digit: number; max: number; min: number }

Type declaration

  • digit: number
  • max: number
  • min: number

ColorCombinationFunc

ColorCombinationFunc<V, R>: ColorFunc<V, R>

Type parameters

  • V = number

  • R = Color

ColorFunc

ColorFunc<V, R>: Func<Color, V, R>

Type parameters

  • V

  • R

ColorModificationFunc

ColorModificationFunc<V>: ColorFunc<V, RGB>

Type parameters

  • V = number

Func

Func<V, V2, R>: (v: V, v2: V2) => R

Type parameters

  • V

  • V2

  • R

Type declaration

    • (v: V, v2: V2): R
    • Parameters

      • v: V
      • v2: V2

      Returns R

MonochromaticOption

MonochromaticOption: { results: number }

Type declaration

  • results: number

Variables

Const colorMatchers

colorMatchers: { cssUnit: RegExp; hex3: RegExp; hex4: RegExp; hex6: RegExp; hex8: RegExp; hsl: RegExp; hsla: RegExp; hsv: RegExp; hsva: RegExp; rgb: RegExp; rgba: RegExp } = (function () {// <http://www.w3.org/TR/css3-values/#integers>const CSS_INTEGER = "[-\\+]?\\d+%?";// <http://www.w3.org/TR/css3-values/#number-value>const CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.const CSS_UNIT = `(?:${CSS_NUMBER})|(?:${CSS_INTEGER})`;// Actual matching.// Parentheses and commas are optional, but not required.// Whitespace can take the place of commas or opening parenconst PERMISSIVE_MATCH3 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`;const PERMISSIVE_MATCH4 = `[\\s|\\(]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})[,|\\s]+(${CSS_UNIT})\\s*\\)?`;return {cssUnit: new RegExp(CSS_UNIT),rgb: new RegExp(`rgb${PERMISSIVE_MATCH3}`),rgba: new RegExp(`rgba${PERMISSIVE_MATCH4}`),hsl: new RegExp(`hsl${PERMISSIVE_MATCH3}`),hsla: new RegExp(`hsla${PERMISSIVE_MATCH4}`),hsv: new RegExp(`hsv${PERMISSIVE_MATCH3}`),hsva: new RegExp(`hsva${PERMISSIVE_MATCH4}`),hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,};})()

Type declaration

  • cssUnit: RegExp
  • hex3: RegExp
  • hex4: RegExp
  • hex6: RegExp
  • hex8: RegExp
  • hsl: RegExp
  • hsla: RegExp
  • hsv: RegExp
  • hsva: RegExp
  • rgb: RegExp
  • rgba: RegExp

Const defaultMax

defaultMax: 1 = 1

Const defaultMin

defaultMin: 0 = 0

Const hexNames

hexNames: Record<string, string> = flip(colorNames)

Const trimLeft

trimLeft: RegExp = /^\s+/

Const trimRight

trimRight: RegExp = /\s+$/

Functions

Const analogous

Const assignDefaultBetweenOption

Const between

  • Force a number between min option and max option, min, max included

    Parameters

    • val: number

      input number

    • Optional opts: Partial<BetweenOption>

      between options (default is [0, 1])

    Returns number

    number between option

Const bound01

Const boundAlpha

  • boundAlpha(a: number, digit?: number): number
  • Return a valid alpha value [0,1] with all invalid values being set to 1

    Parameters

    • a: number

      string or number

    • Default value digit: number = 6

    Returns number

    float number in range [0, 1]

Const brighten

  • brighten(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const cParseFloat

  • cParseFloat(val: type.AnyOptional): number

Const cParseInt

  • cParseInt<T>(val: T, radix?: number): number

Const cParseString

  • cParseString(val: type.AnyOptional): string

Const complement

Const darken

  • darken(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const desaturate

  • desaturate(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const duplicateChar

  • duplicateChar(str: string): boolean

Const flip

  • flip<K, V>(o: Record<K, V>): Record<V, K>
  • { 'name1': 'val1' }becomes{ 'val1': 'name1' }

    Type parameters

    • K: string

    • V: string

    Parameters

    • o: Record<K, V>

      input object

    Returns Record<V, K>

    flip of input object

Const isDecimal

Const isNumber

Const isPercentage

Const isType

Const isValidCSSUnit

  • isValidCSSUnit(color: string): boolean

Const lighten

  • lighten(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const monochromatic

Const pad2

  • pad2(c: string): string

Const percentage

  • percentage(percent: number, opts?: Partial<BetweenOption>, noparser?: boolean): number
  • convert percent type to number format

    Parameters

    • percent: number

      number in format of [0-100] or [0-1] if set noparser to true

    • Optional opts: Partial<BetweenOption>

      between options

    • Default value noparser: boolean = false

      false if percent is format [0-100], or true if you input number as [0-1]

    Returns number

Const rounding

  • rounding(n: number, digit?: number): number
  • round input n to digit

    Parameters

    • n: number

      integer or double

    • Default value digit: number = 2

      how many digit to return (default = 2)

    Returns number

    number

Const saturate

  • saturate(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const spin

  • spin(color: Color, amount: number): C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }
  • Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. Values outside of this range will be wrapped into this range.

    Parameters

    • color: Color
    • amount: number

    Returns C<"r" | "g" | "b", number> & C<"a", number> & C<"type", Type> & { a: number }

Const splitcomplement

Const tetrad

Const triad

Object literals

Const colorNames

colorNames: object

aliceblue

aliceblue: string = "f0f8ff"

antiquewhite

antiquewhite: string = "faebd7"

aqua

aqua: string = "0ff"

aquamarine

aquamarine: string = "7fffd4"

azure

azure: string = "f0ffff"

beige

beige: string = "f5f5dc"

bisque

bisque: string = "ffe4c4"

black

black: string = "000"

blanchedalmond

blanchedalmond: string = "ffebcd"

blue

blue: string = "00f"

blueviolet

blueviolet: string = "8a2be2"

brown

brown: string = "a52a2a"

burlywood

burlywood: string = "deb887"

burntsienna

burntsienna: string = "ea7e5d"

cadetblue

cadetblue: string = "5f9ea0"

chartreuse

chartreuse: string = "7fff00"

chocolate

chocolate: string = "d2691e"

coral

coral: string = "ff7f50"

cornflowerblue

cornflowerblue: string = "6495ed"

cornsilk

cornsilk: string = "fff8dc"

crimson

crimson: string = "dc143c"

cyan

cyan: string = "0ff"

darkblue

darkblue: string = "00008b"

darkcyan

darkcyan: string = "008b8b"

darkgoldenrod

darkgoldenrod: string = "b8860b"

darkgray

darkgray: string = "a9a9a9"

darkgreen

darkgreen: string = "006400"

darkgrey

darkgrey: string = "a9a9a9"

darkkhaki

darkkhaki: string = "bdb76b"

darkmagenta

darkmagenta: string = "8b008b"

darkolivegreen

darkolivegreen: string = "556b2f"

darkorange

darkorange: string = "ff8c00"

darkorchid

darkorchid: string = "9932cc"

darkred

darkred: string = "8b0000"

darksalmon

darksalmon: string = "e9967a"

darkseagreen

darkseagreen: string = "8fbc8f"

darkslateblue

darkslateblue: string = "483d8b"

darkslategray

darkslategray: string = "2f4f4f"

darkslategrey

darkslategrey: string = "2f4f4f"

darkturquoise

darkturquoise: string = "00ced1"

darkviolet

darkviolet: string = "9400d3"

deeppink

deeppink: string = "ff1493"

deepskyblue

deepskyblue: string = "00bfff"

dimgray

dimgray: string = "696969"

dimgrey

dimgrey: string = "696969"

dodgerblue

dodgerblue: string = "1e90ff"

firebrick

firebrick: string = "b22222"

floralwhite

floralwhite: string = "fffaf0"

forestgreen

forestgreen: string = "228b22"

fuchsia

fuchsia: string = "f0f"

gainsboro

gainsboro: string = "dcdcdc"

ghostwhite

ghostwhite: string = "f8f8ff"

gold

gold: string = "ffd700"

goldenrod

goldenrod: string = "daa520"

gray

gray: string = "808080"

green

green: string = "008000"

greenyellow

greenyellow: string = "adff2f"

grey

grey: string = "808080"

honeydew

honeydew: string = "f0fff0"

hotpink

hotpink: string = "ff69b4"

indianred

indianred: string = "cd5c5c"

indigo

indigo: string = "4b0082"

ivory

ivory: string = "fffff0"

khaki

khaki: string = "f0e68c"

lavender

lavender: string = "e6e6fa"

lavenderblush

lavenderblush: string = "fff0f5"

lawngreen

lawngreen: string = "7cfc00"

lemonchiffon

lemonchiffon: string = "fffacd"

lightblue

lightblue: string = "add8e6"

lightcoral

lightcoral: string = "f08080"

lightcyan

lightcyan: string = "e0ffff"

lightgoldenrodyellow

lightgoldenrodyellow: string = "fafad2"

lightgray

lightgray: string = "d3d3d3"

lightgreen

lightgreen: string = "90ee90"

lightgrey

lightgrey: string = "d3d3d3"

lightpink

lightpink: string = "ffb6c1"

lightsalmon

lightsalmon: string = "ffa07a"

lightseagreen

lightseagreen: string = "20b2aa"

lightskyblue

lightskyblue: string = "87cefa"

lightslategray

lightslategray: string = "789"

lightslategrey

lightslategrey: string = "789"

lightsteelblue

lightsteelblue: string = "b0c4de"

lightyellow

lightyellow: string = "ffffe0"

lime

lime: string = "0f0"

limegreen

limegreen: string = "32cd32"

linen

linen: string = "faf0e6"

magenta

magenta: string = "f0f"

maroon

maroon: string = "800000"

mediumaquamarine

mediumaquamarine: string = "66cdaa"

mediumblue

mediumblue: string = "0000cd"

mediumorchid

mediumorchid: string = "ba55d3"

mediumpurple

mediumpurple: string = "9370db"

mediumseagreen

mediumseagreen: string = "3cb371"

mediumslateblue

mediumslateblue: string = "7b68ee"

mediumspringgreen

mediumspringgreen: string = "00fa9a"

mediumturquoise

mediumturquoise: string = "48d1cc"

mediumvioletred

mediumvioletred: string = "c71585"

midnightblue

midnightblue: string = "191970"

mintcream

mintcream: string = "f5fffa"

mistyrose

mistyrose: string = "ffe4e1"

moccasin

moccasin: string = "ffe4b5"

navajowhite

navajowhite: string = "ffdead"

navy

navy: string = "000080"

oldlace

oldlace: string = "fdf5e6"

olive

olive: string = "808000"

olivedrab

olivedrab: string = "6b8e23"

orange

orange: string = "ffa500"

orangered

orangered: string = "ff4500"

orchid

orchid: string = "da70d6"

palegoldenrod

palegoldenrod: string = "eee8aa"

palegreen

palegreen: string = "98fb98"

paleturquoise

paleturquoise: string = "afeeee"

palevioletred

palevioletred: string = "db7093"

papayawhip

papayawhip: string = "ffefd5"

peachpuff

peachpuff: string = "ffdab9"

peru

peru: string = "cd853f"

pink

pink: string = "ffc0cb"

plum

plum: string = "dda0dd"

powderblue

powderblue: string = "b0e0e6"

purple

purple: string = "800080"

rebeccapurple

rebeccapurple: string = "663399"

red

red: string = "f00"

rosybrown

rosybrown: string = "bc8f8f"

royalblue

royalblue: string = "4169e1"

saddlebrown

saddlebrown: string = "8b4513"

salmon

salmon: string = "fa8072"

sandybrown

sandybrown: string = "f4a460"

seagreen

seagreen: string = "2e8b57"

seashell

seashell: string = "fff5ee"

sienna

sienna: string = "a0522d"

silver

silver: string = "c0c0c0"

skyblue

skyblue: string = "87ceeb"

slateblue

slateblue: string = "6a5acd"

slategray

slategray: string = "708090"

slategrey

slategrey: string = "708090"

snow

snow: string = "fffafa"

springgreen

springgreen: string = "00ff7f"

steelblue

steelblue: string = "4682b4"

tan

tan: string = "d2b48c"

teal

teal: string = "008080"

thistle

thistle: string = "d8bfd8"

tomato

tomato: string = "ff6347"

turquoise

turquoise: string = "40e0d0"

violet

violet: string = "ee82ee"

wheat

wheat: string = "f5deb3"

white

white: string = "fff"

whitesmoke

whitesmoke: string = "f5f5f5"

yellow

yellow: string = "ff0"

yellowgreen

yellowgreen: string = "9acd32"

Generated using TypeDoc