@tempots/color

SRGB class

Represents a color in the sRGB color space.

Signature:

declare class SRGB 

Constructors

Constructor

Modifiers

Description

(constructor)(red, blue, green)

Constructs a new instance of the SRGB class

Properties

Property

Modifiers

Type

Description

blue

readonly

number

The blue component of the sRGB color.

equals

readonly

(other: SRGB, tollerance?: number) => boolean

Checks if the current SRGB instance is equal to another SRGB instance.

fromString

static

readonly

(s: string) => SRGB

Creates an SRGB color instance from a string representation of an RGB color. The string should be in the format "rgb(r%, g%, b%)" where r, g, and b are the red, green, and blue color values respectively.

green

readonly

number

The green component of the sRGB color.

ofChannels

static

([red, blue, green]: [red: number, blue: number, green: number]) => SRGB

Creates an SRGB color instance from the given channel values.

red

readonly

number

The red component of the sRGB color.

toChannels

readonly

() => [number, number, number]

Converts the SRGB color to an array of normalized channel values. Each channel value is divided by 100 to obtain a value between 0 and 1.

toString

readonly

() => string

Returns a string representation of the RGB color in the format "rgb(red%, blue%, green%)".

withBlue

readonly

(blue: number) => SRGB

Returns a new SRGB instance with the specified blue value.

withGreen

readonly

(green: number) => SRGB

Returns a new SRGB color with the specified green value.

withRed

readonly

(red: number) => SRGB

Returns a new SRGB color with the specified red value.