# Color

A color in the RGBA color space.

## Constructors

Color(r,g,b,a)→[Color](https://cuttle.xyz/learn/reference/Color)

`r`

`number`

`0`

`g`

`number`

`0`

`b`

`number`

`0`

`a`

`number`

`1`

Color.fromHSVA(h,s,v,a)→[Color](https://cuttle.xyz/learn/reference/Color)

Constructs a color from HSVA color space components.

`h`

`number`

Hue

`s`

`number`

Saturation

`v`

`number`

Value

`a`

`number`

Alpha

Color.fromCSSString(cssString)→[Color](https://cuttle.xyz/learn/reference/Color)

Constructs a color from a CSS color string.

Hexadecimal, rba, rgba, and named CSS color keywords are supported.

See [https://developer.mozilla.org/en-US/docs/Web/CSS/color\_value](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value)

`cssString`

`string`

A CSS color string

Color.fromRGB8Number(value)→[Color](https://cuttle.xyz/learn/reference/Color)

Constructs a color from a bit-packed number in RGB8 format.

`value`

`number`

A bit-packed color value in RGB8 format.

## Properties

.rnumber

The red component

.gnumber

The green component

.bnumber

The blue component

.anumber

The alpha (or opacity) component

## Methods

.clone()→[Color](https://cuttle.xyz/learn/reference/Color)

Returns a copy of this color.

.equals(color)→boolean

`color`

`[Color](https://cuttle.xyz/learn/reference/Color)`

Returns `true` if this color _exactly_ equals `color`.

.set(r,g,b,a)→[Color](https://cuttle.xyz/learn/reference/Color)chainable

Sets the RGBA components of this color.

`r`

`number`

`g`

`number`

`b`

`number`

`a`

`number`

.mix(c,t)→[Color](https://cuttle.xyz/learn/reference/Color)chainable

Linearly interpolates this color to the color `c` by the mixing factor `t`.

`c`

`[Color](https://cuttle.xyz/learn/reference/Color)`

The color to interpolate to

`t`

`number`

The mixing factor

.luminance()→number

Returns the relative luminance of this color for standard human vision.

.toCSSString()→string

Returns a CSS style string for this color.

If fully opaque, this will return a hexadecimal string with a `#` mark at the beginning.

If transparent, it will return a string in the form `rgba(r, g, b, a)`.

.toCSSHexString()→string

Returns a CSS style string for this color in hexadecimal format with a `#` mark at the beginning.

The resulting string will represent an opaque RGB color. The alpha component of transparent colors will be ignored.

The returned string will be a valid CSS2 color.

.toCSSRGBAString()→string

Returns a CSS style string for this color in the form `rgba(r, g, b, a)`.

.toRGB8Number()→number

Returns a bit-packed number in RGB8 format, also knows a "hex" color such as `0xffaabb`.

.toHSVA()→number\[\]

Converts this color to the HSVA color space.

Returns an array of `[hue, saturation, value, alpha]`.