Skip to content

Swatch

Represents a color swatch generated from an image’s palette.

new Swatch(rgb, population): Swatch

Internal use.

Vec3

[r, g, b]

number

Population of the color in an image

Swatch

index.ts:155

get b(): number

The blue value in the RGB value

number

index.ts:74


get bodyTextColor(): string

Returns an appropriate color to use for any ‘body’ text which is displayed over this Swatch’s color.

string

index.ts:143


get g(): number

The green value in the RGB value

number

index.ts:68


get hex(): string

The color value as a hex string

string

index.ts:97


get hsl(): Vec3

The color value as a hsl value

Vec3

index.ts:86


get population(): number

number

index.ts:105


get r(): number

The red value in the RGB value

number

index.ts:62


get rgb(): Vec3

The color value as a rgb value

Vec3

index.ts:80


get titleTextColor(): string

Returns an appropriate color to use for any ‘title’ text which is displayed over this Swatch’s color.

string

index.ts:133

toJSON(): object

Get the JSON object for the swatch

object

population: number;
rgb: Vec3;

index.ts:112


static applyFilters(colors, filters): Swatch[]

Swatch[]

Filter[]

Swatch[]

index.ts:35


static clone(swatch): Swatch

Make a value copy of a swatch based on a previous one. Returns a new Swatch instance

Swatch

Swatch

index.ts:50