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 DuESF.jsxinc, line 2321

Members

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 DuESF.jsxinc, line 2601

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 DuESF.jsxinc, line 2981

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 DuESF.jsxinc, line 2694

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 DuESF.jsxinc, line 2721

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 DuESF.jsxinc, line 2763

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 DuESF.jsxinc, line 2780

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 DuESF.jsxinc, line 2855

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 DuESF.jsxinc, line 2905

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 DuESF.jsxinc, line 2811

true if the color is valid
boolean

# static random() → {DuColor}

Generates a random color, with the alpha == 1.0

View Source DuESF.jsxinc, line 2790

The color
DuColor

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

Generates a random color
Deprecated:
  • Yes

View Source DuESF.jsxinc, line 2836

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 DuESF.jsxinc, line 2883

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 DuESF.jsxinc, line 2945

the RGBA color array
Array.<float>

# adjusted()

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

View Source DuESF.jsxinc, line 2579

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 DuESF.jsxinc, line 2519

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 DuESF.jsxinc, line 2556

true if the colors are the same.
Boolean

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

Returns the HSL values

View Source DuESF.jsxinc, line 2474

the HSL
Array.<float>

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

Returns the HSLA values

View Source DuESF.jsxinc, line 2507

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 DuESF.jsxinc, line 2387

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 DuESF.jsxinc, line 2368

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

# hex() → {string}

Returns the hexcode for this color

View Source DuESF.jsxinc, line 2442

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

# hexA() → {string}

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

View Source DuESF.jsxinc, line 2461

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

# intRGB() → {int}

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

View Source DuESF.jsxinc, line 2417

an [R,G,B] Array.
int

# intRGBA() → {int}

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

View Source DuESF.jsxinc, line 2406

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

# isValid() → {boolean}

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

View Source DuESF.jsxinc, line 2430

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 DuESF.jsxinc, line 2537

The new color
DuColor

# toJSON() → {string}

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

View Source DuESF.jsxinc, line 2569

The JSON
string