Skip to content

Swatch

Class: Swatch

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

Constructors

new Swatch()

new Swatch(rgb, population): Swatch

Internal use.

Parameters

rgb

Vec3

[r, g, b]

population

number

Population of the color in an image

Returns

Swatch

Defined in

index.ts:155

Accessors

b

Get Signature

get b(): number

The blue value in the RGB value

Returns

number

Defined in

index.ts:74


bodyTextColor

Get Signature

get bodyTextColor(): string

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

Returns

string

Defined in

index.ts:143


g

Get Signature

get g(): number

The green value in the RGB value

Returns

number

Defined in

index.ts:68


hex

Get Signature

get hex(): string

The color value as a hex string

Returns

string

Defined in

index.ts:97


hsl

Get Signature

get hsl(): Vec3

The color value as a hsl value

Returns

Vec3

Defined in

index.ts:86


population

Get Signature

get population(): number
Returns

number

Defined in

index.ts:105


r

Get Signature

get r(): number

The red value in the RGB value

Returns

number

Defined in

index.ts:62


rgb

Get Signature

get rgb(): Vec3

The color value as a rgb value

Returns

Vec3

Defined in

index.ts:80


titleTextColor

Get Signature

get titleTextColor(): string

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

Returns

string

Defined in

index.ts:133

Methods

toJSON()

toJSON(): object

Get the JSON object for the swatch

Returns

object

population
population: number;
rgb
rgb: Vec3;

Defined in

index.ts:112


applyFilters()

static applyFilters(colors, filters): Swatch[]

Parameters

colors

Swatch[]

filters

Filter[]

Returns

Swatch[]

Defined in

index.ts:35


clone()

static clone(swatch): Swatch

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

Parameters

swatch

Swatch

Returns

Swatch

Defined in

index.ts:50