Precedence – Apple Shake 4 User Manual

Page 940

Advertising
background image

940

Chapter 31

Expressions and Scripting

You can type an expression in any field. Some nodes, such as ColorX, WarpX, and TimeX,
even support locally declared variables. For more information and a list of examples,
see “

ColorX

” on page 647.

If you are using the command-line method, you may have to enclose your expressions
in quotes to avoid problems with the operating system reading the command. For
example, don’t use:

shake my_image.iff -rot 45*6

Instead, use:

shake my_image.iff -rot “45*6”

Precedence

The above operators are listed in order of precedence—the order Shake evaluates each
operator, left to right. If this is difficult to keep up with (and it is), make liberal use of
parentheses to force the order of evaluation. For instance:

a = 1 + 2 * 4 -2

This expression does “2*4” first, since the “*” has precedence over “+” and “-” which
gives you “a=1+8-2.”Then from left to right, Shake does “1+8,” giving “a=9-2,” finally
resulting in “a=7.” To add and subtract before multiplying, use parentheses to control
the evaluation.

a = (1 + 2) * (4 - 2)

This results in “a=3*2” or “a=6.”

Note: In any expression, parentheses have the highest precedence.

Examples

Explanation

1/2.2

1 divided by 2.2. Gives you the inverse of 2.2 gamma.

2*Linear(0,0@1,200@20)

Multiplies the value of an animated curve by 2.

2*my_curve

Multiplies a variable by 2.

sqrt(my_curve-my_center)/2

Subtracts my_center from my_curve, takes the result square root,
and then divides by 2.

time>20?1:0

If time is greater than 20, then the parameter is 1, otherwise it
equals 0.

cos(time/5)*50

Gives a smooth ping-pong between -50 and 50.

Advertising