Class PaletteColorSelector

A basic ColorSelector that chooses colors from a given Palette.

Hierarchy (view full)

Constructors

  • Parameters

    • palette: Palette

      The Palette from which colors will be selected.

    • Optional buildWithPaletteOrder: boolean

      When true, choosePaletteColors will choose colors in the order they appear in the order they appear in the Palette.COLORS list. If buildWithPaletteOrder is true and randomOrder is false, the order of colors from getColor will match the order of colors in the palette.

    • Optional colorCount: number

      The number of colors available in the selector. This number should be greater than or equal to MIN_COLOR_COUNT and less than or equal to the number of colors in the given palette.

    • Optional randomOrder: boolean

      A flag that determines the color selection order of getColor. When true, colors will be chosen in a random order. When false, colors will be chosen in the order they were selected in choosePaletteColors.

    Returns PaletteColorSelector

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.

  • get MIN_COLOR_COUNT(): number
  • Returns number

    2

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

  • Build the name of the selector from the name of the given Palette.

    Parameters

    Returns string

  • Choose the colors from the given Palette that will be available in the selector.

    Parameters

    • palette: Palette
    • buildWithPaletteOrder: boolean

      When true, colors will be chosen from the palette in the order they appear in the Palette.COLORS list. When false, colors will be chosen from the palette in random order.

    • colorCount: number

      The number of colors to choose from the palette. This number should be greater than or equal to MIN_COLOR_COUNT and less than or equal to the number of colors in the given palette.

    Returns void