beautypg.com

Starting the macro format – Apple Shake 4 Tutorials User Manual

Page 230

background image

230

Chapter 8

Working With Macros

The text in your editor is raw script, meaning it is not formatted as a macro. If you paste
it back in, you get three more nodes. You need to format the text as a single function—
a macro.

7

Delete the layout information—that is, everything in the text editor window including
and below the “User interface settings” line.

These lines tell Shake where to place the nodes if you paste them back in again. You do
not need the lines, so remove them.

You are left with this:

Rotate1 = Rotate(0, -Rotate2.angle, 1, width/2, height/2, 0, 0.5, 0);
Blur1 = Blur(Rotate1, 200, 0, 1, "gauss", xFilter, "rgba");
Rotate2 = Rotate(Blur1, -36.9218, 1, width/2, height/2, 0, 0.5, 0);

The left side of the argument supplies a variable name. In the above example, there are
three variables: Rotate1, Blur1, and Rotate2. These are assigned to Shake functions, the
Rotate and the Blur functions. (Inside the Shake interface, these are referred to as
“nodes.” Inside a script, they are referred to as “functions,” as you can have other types
of functions.) Next are the values for the functions. The first argument is generally the
incoming image, so you can see that the incoming image for Blur1 is the result of the
first Rotate function, Rotate1. Rotate1 has a value of 0 as the incoming image—there is
no expected input. If you look these functions up in the documentation, you find the
scripting format for each function.

If you change the variable names Rotate1, Blur1, and Rotate2, you must modify every
reference to them.

The following is used as an example only (it is not a step in the tutorial):

Marshall = Rotate(0, -Holly.angle,1, width/2, height/2, 0, .5, 0);
Will = Blur(Marshall, 200, 0, 1, "gauss", xFilter, "rgba");
Holly = Rotate(Will, 42.61728, 1, width/2, height/2, 0, 0.5, 0);

Notice how the strings “gauss” and “rgba” are in quotation marks because they are
strings, meaning letter data rather than numeric data. Compare these to what you see in
the interface parameters tab to get an idea of how Shake saves its parameters in a script.

Starting the Macro Format

Next, add some formatting. You must declare the type of the macro—if the macro spits
out an image, an integer (int), a number with decimal place (float), or a word (string).
Because this macro modifies an image, it needs to return an image. After that, add the
macro name. In this case, name the macro RotateBlur, capitalizing each word for
consistency.

Also, include two sets of parentheses. Incoming variables are placed in the first set, and
the second set {the braces} surrounds the body of the macro.