Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Palette

A manager that handles both the PLTE and tRNS chunks, as they depend upon each other.

export
class

Palette

Hierarchy

  • Palette

Index

Constructors

constructor

Methods

addColor

  • addColor(rgba: RGBA | RGB): number
  • Add a color to the palette. Must be an RGBA color, even if we're not using tRNS (to do: fix that)

    memberof

    Palette

    Parameters

    Returns number

    the index the color was added at.

getColorAtIndex

  • getColorAtIndex(idx: number): Object
  • Return the RGBA color at the index provided. If there is no tRNS chunk the color will always have an alpha value of 255.

    memberof

    Palette

    Parameters

    • idx: number

    Returns Object

    The RGBA color at this index. If the color hasn't been specified it will come back as [0,0,0,255].

getColorIndex

  • getColorIndex(rgba: RGBA | RGB, startingIndex?: number): number
  • Get the palette index for an existing color.

    memberof

    Palette

    Parameters

    • rgba: RGBA | RGB
    • Default value startingIndex: number = 0

    Returns number

    The index of the color, or -1 if the color has not yet been added to the palette.

writeCRCs

  • writeCRCs(): void

Generated using TypeDoc