beautypg.com

Vector math methods (expression reference) – Adobe After Effects CS4 User Manual

Page 668

background image

662

USING AFTER EFFECTS CS4

Expressions

Last updated 12/21/2009

timeToCurrentFormat(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false)

Return type: String.

Argument type: t and fps are Numbers; isDuration is a Boolean.

Converts the value of t to a String representing time in the current Project Settings display format. See

timeToFrames

for a definition of all of the arguments.

If you want more control over the look of timecode in your footage, use the

timeToCurrentFormat

method or other

timeTo

methods to generate the timecode instead of using the Timecode or Numbers effect. Create a text layer, add

an expression to the Source Text property, and enter

timeToCurrentFormat()

in the expression field. With this method,

you can format and animate the timecode text. In addition, the timecode uses the same display style defined by the current
project settings.

More Help topics

Time display units

” on page 52

Vector Math methods (expression reference)

Vector Math functions are global methods that perform operations on arrays, treating them as mathematical vectors.
Unlike built-in JavaScript methods, such as

Math.sin

, these methods are not used with the

Math

prefix. Unless

otherwise specified, Vector Math methods are lenient about dimensions and return a value that is the dimension of
the largest input Array object, filling in missing elements with zeros. For example, the expression

add([10, 20], [1,

2, 3])

returns

[11, 22, 3]

.

JJ Gifford’s website

provides explanations and examples that show how to use simple geometry and trigonometry with

expressions.

add(vec1, vec2)

Return type: Array.

Argument type: vec1 and vec2 are Arrays.

Adds two vectors.

sub(vec1, vec2)

Return type: Array.

Argument type: vec1 and vec2 are Arrays.

Subtracts two vectors.

mul(vec, amount)

Return type: Array.

Argument type: vec is an Array, amount is a Number.

Multiplies every element of the vector by the amount.

div(vec, amount)

Return type: Array.

Argument type: vec is an Array, amount is a Number.

Divides every element of the vector by the amount.

clamp(value, limit1, limit2)

Return type: Number or Array.

Argument type: value, limit1, and limit2 are Numbers or Arrays.

The value of each component of value is constrained to fall between the values of the corresponding values of limit1
and limit2.

dot(vec1, vec2)

Return type: Number.

This manual is related to the following products: