Skip to content

Color

Stores color data including opacity.

A color can be created using a hex value, e.g. #FF0000 and optionally an alpha or it can be created using the provided system colors.

Alpha of the color.

alpha: number

Read-only.

Amount of blue in the color.

blue: number

Read-only.

Amount of green in the color.

green: number

Read-only.

HEX representation.

hex: string

Read-only.

Amount of red in the color.

red: number

Read-only.

Constructs a color.

new Color(hex: string, alpha: number)

Constructs a new color with a hex value and optionally an alpha value. The hex value may specify the alpha value but this will be ignored if the alpha value parameter is provided. Examples of valid hex values: #ff0000, #00ff0080 #00f and #ff. The hashtag is optional.

hex string

Hex value.

alpha number

Alpha value.

Constructs a black color.

static black(): Color

Color

A black color.

Constructs a blue color.

static blue(): Color

Color

A blue color.

Constructs a brown color.

static brown(): Color

Color

A brown color.

Constructs a transparent color.

static clear(): Color

Color

A transparent color.

Constructs a cyan color.

static cyan(): Color

Color

A cyan color.

Constructs a dark gray color.

static darkGray(): Color

Color

A dark gray color.

Creates a dynamic color.

static dynamic(lightColor: Color, darkColor: Color): Color

The dynamic color will use either its light or dark variant depending the appearance of the system.

DrawContext resolves the color when drawing in the app. The resulting image keeps that color when the appearance changes.

lightColor Color

Color used in light appearance.

darkColor Color

Color used in dark appearance.

Color

Dynamic color.

Constructs a gray color.

static gray(): Color

Color

A gray color.

Constructs a green color.

static green(): Color

Color

A green color.

Constructs a light gray color.

static lightGray(): Color

Color

A light gray color.

Constructs a magenta color.

static magenta(): Color

Color

A magenta color.

Constructs a orange color.

static orange(): Color

Color

A orange color.

Constructs a purple color.

static purple(): Color

Color

A purple color.

Constructs a red color.

static red(): Color

Color

A red color.

Constructs a white color.

static white(): Color

Color

A white color.

Constructs a yellow color.

static yellow(): Color

Color

A yellow color.