Skip to main content
Version: Version 5

Class: RgbaColor

Represents a color with red, green, blue, and alpha components.

Extends

Implements

Constructors

Constructor

new RgbaColor(colorString): RgbaColor

Creates a new RgbaColor instance from a string representation (hex, rgb, rgba or hsl).

Parameters

colorString

string

The string representation of the color.

Returns

RgbaColor

Throws

If the input string is not a valid color representation.

Overrides

RgbColor.constructor

Constructor

new RgbaColor(r?, g?, b?, a?): RgbaColor

Creates a new RgbaColor instance.

Parameters

r?

number

The red component of the color (0 to 255).

g?

number

The green component of the color (0 to 255).

b?

number

The blue component of the color (0 to 255).

a?

number

The alpha (transparency) component of the color (0 to 1).

Returns

RgbaColor

Overrides

RgbColor.constructor

Properties

a

a: number

The alpha component of the color (0 to 1).


b

b: number

The blue component of the color (0 to 255).

Inherited from

RgbColor.b


g

g: number

The green component of the color (0 to 255).

Inherited from

RgbColor.g


r

r: number

The red component of the color (0 to 255).

Inherited from

RgbColor.r

Accessors

blue

Get Signature

get blue(): number

The intensity of blue in the described color as a value 0-255.

Returns

number

Inherited from

RgbColor.blue


green

Get Signature

get green(): number

The intensity of green in the described color as a value 0-255.

Returns

number

Inherited from

RgbColor.green


red

Get Signature

get red(): number

The intensity of red in the described color as a value 0-255.

Returns

number

Inherited from

RgbColor.red

Methods

clone()

clone(): RgbaColor

Creates a deep copy of the object.

Returns

RgbaColor

A new instance that is a deep copy of the original object.

Implementation of

Cloneable.clone

Overrides

RgbColor.clone


setRGB()

setRGB(red, green, blue): void

Set a new color with all components at once

Parameters

red

number

green

number

blue

number

Returns

void

Inherited from

RgbColor.setRGB


toHexString()

toHexString(): string

Converts the color to a hexadecimal string

Returns

string

A string representation of the color in hexadecimal

Example

#330000

Inherited from

RgbColor.toHexString


toRgbaString()

toRgbaString(): string

Converts the color to a CSS-formatted RGBA string.

Returns

string

A string representation of the color in RGBA format.

Overrides

RgbColor.toRgbaString


toRgbString()

toRgbString(): string

Converts the color to a CSS-formatted RGB string.

Returns

string

A string representation of the color in RGB format.

Inherited from

RgbColor.toRgbString