DuAEF.DuExpression.Library

Expression Library

Members

static isSpatial

Checks if a property is spatial

Methods

static addNoise(val, quantity)

Adds some noise to a value.
You may use seedRandom() before using this function as it will influence the generated noise. A timeless noise can be achieved with seedRandom(index,true) for example.
Parameters:
Name Type Description
val number | Array.<number> The value to add noise to.
quantity float The quantity of noise. A percentage. 100 means the value can range from (val * 0) to (val * 2).
Examples
seedRandom(index, true) // a timeless noise
addNoise(value, 50 ); // the property value will have noise between (value * 0.5) and (value * 1.5) which won't vary through time.
seedRandom(index, false);
addNoise(value, 33 ); // the noise will change at each frame, varying between (value * .66) and (value * 1.33)

static bezier(t, tMin, tMax, value1, value2) → {Array.<number>}

Interpolates a value with a bezier curve.
This method can replace linear() and ease() with a custom b�zier interpolation.
Parameters:
Name Type Description
t number The value to interpolate
tMin number The minimum the value can take
tMax number The maximum the value can take
value1 number The minimum for the interpolated value
value2 number The maximum for the interpolated value
Returns:
Array.<number> - bezierPoints an Array of 4 coordinates wihtin the 0.0 ... 1.0 range which describes the B�zier interpolation.
[ outTangentX, outTangentY, inTangentX, inTangentY ]

static checkDuikEffect(fx, duikMatchName) → {boolean}

Checks the type of a pseudo-effect used by Duik.
This is a workaround for the missing matchName in expressions.
Pseudo-Effects used by Duik start with a hidden property which name is the same as the matchName of the effect itself (without the 'Pseudo/' part).
Parameters:
Name Type Description
fx Property The effect to check
duikMatchName string The matchName of a pseudo-effect used by Duik (without the 'Pseudo/' part)
Returns:
boolean - True when the property at propIndex is named propName
Example
if ( checkEffect(thisLayer.effect(1), "DUIK parentConstraint2") ) { "This is the second version of the parent constraint by Duik" }
else { "Who knows what this is?" }

static checkEffect(fx, propIndex, propName) → {boolean}

Checks the type of an effect.
This is a workaround for the missing matchName in expressions.
It checks if the given effect has a specific property at a specific index.
Parameters:
Name Type Description
fx Property The effect to check
propIndex int The index of the property
propName string The expected name of the property. Be careful with the internationalization of After Effects...
Returns:
boolean - True when the property at propIndex is named propName
Example
if ( checkEffect(thisLayer.effect(1), 1, "Blur") ) { "The first effect is a blur!" }
else { "Who knows what this is?" }

static dishineritRotation(lopt) → {float}

Removes the ancestors rotation from the rotation of a layer. This is very useful to make a layer keep its orientation without being influenced by its parents.
Parameters:
Name Type Attributes Default Description
l Layer <optional>
thisLayer The layer
Returns:
float - The new rotation value, in degrees.
Examples
//in a rotation property, just include the function and use:
dishineritRotation();
//the layer will now keep its own orientation.
//you can also combine the result with something else
var result = dishineritRotation();
result + wiggle(5,20);

static getCompScale(lopt, topt) → {number}

Gets the "real" scale of a layer, resulting to its scale property, the scale of its parents, and it's location in Z-space if it's 3D.
Parameters:
Name Type Attributes Default Description
l Layer <optional>
thisLayer The layer
t number <optional>
time The time when to get the scale
Returns:
number - The scale ratio. This is not a percent, 1.0 is 100%.

static getEffectLayer(fx, ind) → {Layer|null}

Gets a layer from a layer property in an effect, without generating an error if "None" is selected with the Legacy expression engine.
Parameters:
Name Type Description
fx Property The effect
ind int | string The index or the name of the property
Returns:
Layer | null - The layer, or null if set to "None"

static getLayerCompPos(topt, lopt) → {Array.<number>}

Gets the comp position (2D Projection in the comp) of a layer.
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time from when to get the position
l Layer <optional>
thisLayer The layer
Returns:
Array.<number> - The comp position

static getLayerWorldPos(topt, lopt) → {Array.<number>}

Gets the world position of a layer.
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time from when to get the position
l Layer <optional>
thisLayer The layer
Returns:
Array.<number> - The world position

static getLayerWorldSpeed(topt, lopt) → {number}

Gets the world instant speed of a layer.
Parameters:
Name Type Attributes Default Description
t number <optional>
time The time when to get the velocity
l Layer <optional>
thisLayer The layer
Requires:
  • module:getLayerWorldVelocity
  • module:getLayerWorldPos
Returns:
number - A positive number. The speed.

static getLayerWorldVelocity(topt, lopt) → {Array.<number>}

Gets the world instant velocity of a layer.
Parameters:
Name Type Attributes Default Description
t number <optional>
time The time when to get the velocity
l Layer <optional>
thisLayer The layer
Requires:
  • module:getLayerWorldPos
Returns:
Array.<number> - The velocity.

static getNextKey(topt) → {Key|null}

Gets the key immediately after the given time
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time at which to get the key
Returns:
Key | null - The key, or null if there's no key before.

static getOrientation(l) → {float}

Gets the world orientation of a (2D) layer.
Parameters:
Name Type Description
l Layer The layer to get the orientation from
Returns:
float - The orientation, in degrees.

static getOrientationAtTime(l, topt) → {float}

Gets the world orientation of a (2D) layer at a specific time.
Parameters:
Name Type Attributes Default Description
l Layer The layer to get the orientation from
t float <optional>
time The time at which to get the orientation
Returns:
float - The orientation, in degrees.

static getPrevKey(topt) → {Key|null}

Gets the key immediately before the given time
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time at which to get the key
Returns:
Key | null - The key, or null if there's no key before.

static getPropWorldSpeed(topt, propopt) → {Array.<number>}

Gets the world speed of a property.
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time from when to get the position
prop Layer <optional>
thisProperty The property
Requires:
  • module:getPropWorldVelocity
  • module:getPropWorldValue
  • module:getLayerWorldPos
Returns:
Array.<number> - The world speed

static getPropWorldValue(topt, propopt) → {Array.<number>}

Gets the world coordinates of a property.
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time from when to get the position
prop Layer <optional>
thisProperty The property
Requires:
  • module:getLayerWorldPos
Returns:
Array.<number> - The world coordinates

static getPropWorldVelocity(topt, propopt) → {Array.<number>}

Gets the world velocity of a property.
Parameters:
Name Type Attributes Default Description
t number <optional>
time Time from when to get the position
prop Layer <optional>
thisProperty The property
Requires:
  • module:getPropWorldValue
  • module:getLayerWorldPos
Returns:
Array.<number> - The world velocity

static isAfterLastKey() → {boolean}

Checks if current time is after the time of the last key in the property
Returns:
boolean - true if time is > lastkey.time

static isPosition(propopt) → {boolean}

Checks if a property is a transform.position property.
Parameters:
Name Type Attributes Default Description
prop Property <optional>
thisProperty The property
Returns:
boolean - true if the property is the transform.position property.

static isStill(topt, thresholdopt) → {boolean}

Checks if the current property is animated at a given time.
Parameters:
Name Type Attributes Default Description
t number <optional>
time The time
threshold number <optional>
0.1 The speed under which the property is considered still.
Returns:
boolean - true if the property does not vary.

static translatePointWithLayer(l, pointopt, startTopt, endTopt) → {Array.<float>}

Translates a point with a layer, as if it was parented to it.
Parameters:
Name Type Attributes Default Description
l Layer The layer to get the translation from.
point Array.<float> <optional>
[0,0] The [X,Y] point to translate (using world coordinates).
startT float <optional>
0 The start time of the translation
endT float <optional>
time The end time of the translation
Returns:
Array.<float> - The coordinates of the translated point.