## DuColor(floatRGBAopt)

A simple class to manage colors and convert them.
Constructor

#### # new DuColor(floatRGBAopt)

Constructs a new color object

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`floatRGBA` | `Array.<float>` | <optional> | [0,0,0,1] | An [R,G,B,A] float Array. Negative values are clamped to 0. Alpha > 1 is clamped to 1. Colors are stored in 32 bit float to keep the maximum precision.

##### Properties:

Name | Type | Description
--- | --- | ---
`red` | `float` | The red value
`green` | `float` | The green value
`blue` | `float` | The blue value
`alpha` | `float` | The alpha value

View Source Duik_api_fordoc.jsxinc, line 2350

# Members

Type: `Array.<DuColor>`

#### # static readonly Color

Enum for predefined colors. float [R,G,B,A]

##### Properties:

Name | Type | Description
--- | --- | ---
`TRANSPARENT` | `Array.<DuColor>` |
`BLACK` | `Array.<DuColor>` |
`WHITE` | `Array.<DuColor>` |
`OBSIDIAN` | `Array.<DuColor>` |
`ABYSS_GREY` | `Array.<DuColor>` |
`VERY_DARK_GREY` | `Array.<DuColor>` |
`DARK_GREY` | `Array.<DuColor>` |
`LIGHT_GREY` | `Array.<DuColor>` |
`VERY_LIGHT_GREY` | `Array.<DuColor>` |
`RAINBOX_RED` | `Array.<DuColor>` |
`ORANGE` | `Array.<DuColor>` |
`YELLOW_ORANGE` | `Array.<DuColor>` |
`YELLOW` | `Array.<DuColor>` |
`GREEN` | `Array.<DuColor>` |
`LIGHT_GREEN` | `Array.<DuColor>` |
`LIGHT_BLUE` | `Array.<DuColor>` |
`LIGHT_PURPLE` | `Array.<DuColor>` |
`AE_DARK_GREY` | `Array.<DuColor>` |
`AFTER_EFFECTS_BLUE` | `Array.<DuColor>` |
`RX_PURPLE` | `Array.<DuColor>` |
`APP_BACKGROUND_COLOR` | `Array.<DuColor>` |
`APP_HIGHLIGHT_COLOR` | `Array.<DuColor>` |
`APP_TEXT_COLOR` | `Array.<DuColor>` |
`AE_ORANGE` | `Array.<DuColor>` |

View Source Duik_api_fordoc.jsxinc, line 2630

# Methods

#### # static eightBpcToFloat(color) → {Array.<float>}

Converts an 8bpc color array to a 32bpc float color array

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | `Array.<int>` | The RGB(A) color array in 8bpc (0-255 range)

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 3010

Returns:
the RGBA color array
Type: `Array.<float>`

#### # static fromHex(hexColor) → {DuColor}

Creates a new DuColor from a hex code/array

##### Parameters:

Name | Type | Description
--- | --- | ---
`hexColor` | `string` | `Array.<int>` | The hexadecimal color

View Source Duik_api_fordoc.jsxinc, line 2723

Returns:
The color
Type: `DuColor`

#### # static fromHSL(hsl) → {DuColor}

Creates a new color from HSL(A) values

##### Parameters:

Name | Type | Description
--- | --- | ---
`hsl` | `Array.<float>` | the HSL(A) values

View Source Duik_api_fordoc.jsxinc, line 2750

Returns:
the color.
Type: `DuColor`

#### # static fromInt(source) → {DuColor}

Creates a new color from an 8-bit int RGB(A) array

##### Parameters:

Name | Type | Description
--- | --- | ---
`source` | `Array.<int>` | The 8-bit int RGB(A) array

View Source Duik_api_fordoc.jsxinc, line 2792

Returns:
Type: `DuColor`

#### # static fromJSON(json) → {DuColor}

Creates a color from a JSON string; Actually a JSON RGBA float Array.

##### Parameters:

Name | Type | Description
--- | --- | ---
`json` | `string` | The JSON string

View Source Duik_api_fordoc.jsxinc, line 2809

Returns:
The color
Type: `DuColor`

#### # static hexToRGB(hexColor, isStringopt) → {Array.<float>}

Converts an hexadecimal color to a floatRGBA Array

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`hexColor` | `string` | `Array.<int>` |  |  | The hexadecimal color
`isString` | `boolean` | <optional> | true | Whether hexColor is a string or an Array of int of base 16

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2884

Returns:
The color as an [R,G,B,A] Array with float values between 0.0 and 1.0
Type: `Array.<float>`

#### # static hslToRgb(color) → {Array.<float>}

Converts an HSL color to RGB

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | `Array.<float>` | The RGBA color array

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2934

Returns:
the HSLA color array
Type: `Array.<float>`

#### # static isValid(color, ignoreAlphaopt) → {boolean}

Checks if this color is valid ([R,G,B,A] in the range 0.0 ... 1.0)

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`color` | `Array.<float>` |  |  | The floatRGBA color to validate
`ignoreAlpha` | `boolean` | <optional> | false | Will return true even if the array does not have any alpha value

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2840

Returns:
true if the color is valid
Type: `boolean`

#### # static random() → {DuColor}

Generates a random color, with the alpha == 1.0

View Source Duik_api_fordoc.jsxinc, line 2819

Returns:
The color
Type: `DuColor`

#### # static randomFloatRGBA() → {Array.<float>}

Generates a random color

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2865

Returns:
The color as an [R,G,B,A] Array with float values between 0.0 and 1.0
Type: `Array.<float>`

#### # static rgbToHex(rgbColor) → {string}

Converts an RGB color to a hex string

##### Parameters:

Name | Type | Description
--- | --- | ---
`rgbColor` | `Array.<float>` | The rgb color

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2912

Returns:
The color as an hex string
Type: `string`

#### # static rgbToHsl(color) → {Array.<float>}

Converts an RGB color to HSL

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | `Array.<float>` | The HSLA color array

Deprecated:
  - Yes

View Source Duik_api_fordoc.jsxinc, line 2974

Returns:
the RGBA color array
Type: `Array.<float>`

#### # adjusted()

Creates a color adjusted according to the brightness setting of the application.
For now, works only in After Effects

View Source Duik_api_fordoc.jsxinc, line 2608

Returns:
The new color

#### # darker(ratioopt) → {DuColor}

Creates a new color darker than the current one

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`ratio` | `int` | <optional> | 200 | A percentage: 200 means twice darker, 50 twice lighter

View Source Duik_api_fordoc.jsxinc, line 2548

Returns:
The new color
Type: `DuColor`

#### # equals(ignoreAlphaopt, precisionopt) → {Boolean}

Compares two colors

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`ignoreAlpha` | `Boolean` | <optional> | false | Set to true to consider colors to be equal if they differ only by their alpha.
`precision` | `int` | <optional> | 4 | The precision to use (the number of decimals to compare).

View Source Duik_api_fordoc.jsxinc, line 2585

Returns:
true if the colors are the same.
Type: `Boolean`

#### # floatHSL() → {Array.<float>}

Returns the HSL values

View Source Duik_api_fordoc.jsxinc, line 2503

Returns:
the HSL
Type: `Array.<float>`

#### # floatHSLA() → {Array.<float>}

Returns the HSLA values

View Source Duik_api_fordoc.jsxinc, line 2536

Returns:
the HSL
Type: `Array.<float>`

#### # floatRGB(clampedopt) → {float}

Returns the color as a float Array without alpha

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`clamped` | `bool` | <optional> | true | Set to false to keep the values > 1.0

View Source Duik_api_fordoc.jsxinc, line 2416

Returns:
an [R,G,B] Array.
Type: `float`

#### # floatRGBA(clampedopt) → {float}

Returns the color as a float Array with alpha

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`clamped` | `bool` | <optional> | true | Set to false to keep the values > 1.0

View Source Duik_api_fordoc.jsxinc, line 2397

Returns:
an [R,G,B,A] Array.
Type: `float`

#### # hex() → {string}

Returns the hexcode for this color

View Source Duik_api_fordoc.jsxinc, line 2471

Returns:
The hex code, without the leading '#'.
Type: `string`

#### # hexA() → {string}

Returns the hexcode for this color, including the alpha (at the end)

View Source Duik_api_fordoc.jsxinc, line 2490

Returns:
The hex code, without the leading '#'.
Type: `string`

#### # intRGB() → {int}

Returns the color as an 8-bit int Array without alpha

View Source Duik_api_fordoc.jsxinc, line 2446

Returns:
an [R,G,B] Array.
Type: `int`

#### # intRGBA() → {int}

Returns the color as an 8-bit int Array with alpha

View Source Duik_api_fordoc.jsxinc, line 2435

Returns:
an [R,G,B,A] Array.
Type: `int`

#### # isValid() → {boolean}

true if [R,G,B,A] in the range 0.0 ... 1.0

View Source Duik_api_fordoc.jsxinc, line 2459

Returns:
true if the color is valid
Type: `boolean`

#### # lighter(ratioopt) → {DuColor}

Creates a new color lighter than the current one

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`ratio` | `int` | <optional> | 200 | A percentage: 200 means twice lighter, 50 twice darker

View Source Duik_api_fordoc.jsxinc, line 2566

Returns:
The new color
Type: `DuColor`

#### # toJSON() → {string}

Creates a JSON string representation of the color; Actually an RGBA float Array.

View Source Duik_api_fordoc.jsxinc, line 2598

Returns:
The JSON
Type: `string`