Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utility"

Index

Type aliases

HexColor

HexColor: string
deprecated

HexColor is a string alias that should be a valid hex-formatted color. It doesn't seem to be currently used anywhere, so it might be good to remove it, or at least, fully implement it.

Variables

DayFromInt

DayFromInt: string[] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]

Enumerates days of week, starting from Monday.

Functions

RgbFromHsl

  • RgbFromHsl(h: number, s: number, l: number): [number, number, number]
  • Converts a given HSL format color into an RGB color.

    Parameters

    • h: number

      Represents the hue. In range [0, 360).

    • s: number

      Represents the saturation. In range [0, 1].

    • l: number

      Represents the luminosity. In range [0, 1].

    Returns [number, number, number]

    An RGB color as a 3-length array of three integers in range [0, 255].

arrmax

  • arrmax<T>(arr: Array<T>, predicate: function): T
  • Returns the largest value in the given array, with a custom predicate function.

    Type parameters

    • T

    Parameters

    • arr: Array<T>

      The array to search in.

    • predicate: function

      he comparison function to use when comparing elements.

        • (T: any): number
        • Parameters

          • T: any

          Returns number

    Returns T

    The largest value in the given array.

arrmin

  • arrmin<T>(arr: Array<T>, predicate: function): T
  • Returns the smallest value in the given array, with a custom predicate function.

    Type parameters

    • T

    Parameters

    • arr: Array<T>

      The array to search in.

    • predicate: function

      The comparison function to use when comparing elements.

        • (T: any): number
        • Parameters

          • T: any

          Returns number

    Returns T

    The smallest value in the given array.

cmptime

  • This function compares the two given Time arguments, essentially returning the result of t1 <= t2.

    Parameters

    Returns boolean

findTextWidth

  • findTextWidth(text: string, font: string, target: number): number
  • Uses getTextWidth() and a trial-and-error approach to fitting a given string into a given area.

    Parameters

    • text: string

      The text to be rendered.

    • font: string

      The name of the font-family to render in.

    • target: number

      The target width.

    Returns number

    The appropriate font size so that the text is at most target pixels wide.

getTextWidth

  • getTextWidth(text: string, font: string): number

hexFromRgb

  • hexFromRgb(rgb: [number, number, number]): string
  • Converts a given RGB color array into a hexcode format color.

    Parameters

    • rgb: [number, number, number]

      An RGB color as a 3-length array of three integers in range [0, 255].

    Returns string

    A hexcode format color string, represented as #RRGGBB.

identity

  • identity<T>(thing: T): T
  • Identity function that returns the provided parameter.

    Type parameters

    • T

    Parameters

    • thing: T

    Returns T

isNull

  • isNull(thing: any): boolean
  • Checks if an object is null.

    Parameters

    • thing: any

      The object to determine nullness.

    Returns boolean

sanitizeForSelector

  • sanitizeForSelector(text: string): string
  • Sanitizes a given string so that it is appropriate for a selector. Replaces illegal characters with an underscore.

    Parameters

    • text: string

      String to be sanitized.

    Returns string

tweenText

  • tweenText(): function

Generated using TypeDoc