Class

DuColor

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 2284

Members

DuColor

# static readonly Color

Enum for predefined colors. float [R,G,B,A]
Properties:
Name Type Description
TRANSPARENT DuColor
BLACK DuColor
WHITE DuColor
OBSIDIAN DuColor
ABYSS_GREY DuColor
VERY_DARK_GREY DuColor
DARK_GREY DuColor
LIGHT_GREY DuColor
VERY_LIGHT_GREY DuColor
RAINBOX_RED DuColor
ORANGE DuColor
YELLOW_ORANGE DuColor
YELLOW DuColor
GREEN DuColor
LIGHT_GREEN DuColor
LIGHT_BLUE DuColor
LIGHT_PURPLE DuColor
AE_DARK_GREY DuColor
AFTER_EFFECTS_BLUE DuColor
RX_PURPLE DuColor
APP_BACKGROUND_COLOR DuColor
APP_HIGHLIGHT_COLOR DuColor
APP_TEXT_COLOR DuColor
AE_ORANGE DuColor

View Source Duik_api_fordoc.jsxinc, line 2564

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 2944

the RGBA color array
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 2657

The color
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 2684

the color.
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 2726

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 2743

The color
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 2818

The color as an [R,G,B,A] Array with float values between 0.0 and 1.0
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 2868

the HSLA color array
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 2774

true if the color is valid
boolean

# static random() → {DuColor}

Generates a random color, with the alpha == 1.0

View Source Duik_api_fordoc.jsxinc, line 2753

The color
DuColor

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

Generates a random color
Deprecated:
  • Yes

View Source Duik_api_fordoc.jsxinc, line 2799

The color as an [R,G,B,A] Array with float values between 0.0 and 1.0
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 2846

The color as an hex string
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 2908

the RGBA color array
Array.<float>

# adjusted() → {DuColor}

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 2542

The new color
DuColor

# 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 2482

The new color
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 2519

true if the colors are the same.
Boolean

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

Returns the HSL values

View Source Duik_api_fordoc.jsxinc, line 2437

the HSL
Array.<float>

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

Returns the HSLA values

View Source Duik_api_fordoc.jsxinc, line 2470

the HSL
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 2350

an [R,G,B] Array.
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 2331

an [R,G,B,A] Array.
float

# hex() → {string}

Returns the hexcode for this color

View Source Duik_api_fordoc.jsxinc, line 2405

The hex code, without the leading '#'.
string

# hexA() → {string}

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

View Source Duik_api_fordoc.jsxinc, line 2424

The hex code, without the leading '#'.
string

# intRGB() → {int}

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

View Source Duik_api_fordoc.jsxinc, line 2380

an [R,G,B] Array.
int

# intRGBA() → {int}

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

View Source Duik_api_fordoc.jsxinc, line 2369

an [R,G,B,A] Array.
int

# isValid() → {boolean}

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

View Source Duik_api_fordoc.jsxinc, line 2393

true if the color is valid
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 2500

The new color
DuColor

# toJSON() → {string}

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

View Source Duik_api_fordoc.jsxinc, line 2532

The JSON
string