Class ColorSelectorAbstract

ColorSelectors choose and return colors from some set list or criteria.

Hierarchy (view full)

Constructors

Properties

_COLOR_CHOICES: Color[] = []

A list of Color objects that the selector can choose from.

_COLOR_NAMES: Set<string> = ...

A set of the names of the colors that can be or have been chosen by the color selector.

_NAME: string

The name of the color selector.

_RANDOM_ORDER: boolean

A flag that determines the color selection order of selectColorFromChoices.
When true, selectColorFromChoices will select colors from _COLOR_CHOICES in a random order.
When false, selectColorFromChoices will select colors list order.

_currentIndex: number = 0

The current index of _COLOR_CHOICES being chosen when colors are selected in list order (i.e. _RANDOM_ORDER is false).

Accessors

  • get colorNames(): string[]
  • Returns string[]

    The names of the colors that can be or have been chosen by the color selector.

  • get name(): string
  • Returns string

    The name of the selector (e.g. 'blue rgb color selector').

  • get COLOR_NAMES(): Set<string>
  • Returns Set<string>

    The _COLOR_NAMES set.

Methods

  • Select and return a Color object to be used as a background. The color will either be black (#000000), white (#FFFFFF), or a color from the selector, chosen by the getColor method.
    IMPORTANT: The sum of chanceOfBlack, chanceOfWhite, and chanceOfColor should be equal to 1.0.

    Parameters

    • chanceOfBlack: number

      The percent (0-1) chance that the chosen color will be black (#000000). The sum of all percentages should be equal to 1.0.

    • chanceOfWhite: number

      The percent (0-1) chance that the chosen color will be white (#FFFFFF). The sum of all percentages should be equal to 1.0.

    • chanceOfColor: number

      The percent (0-1) chance that the chosen color will be a color from the selector (getColor). The sum of all percentages should be equal to 1.0.

    Returns Color

  • Select and return a Color object.

    Returns Color

  • Add a Color to the _COLOR_CHOICES list.

    Parameters

    Returns void