Apple Shake 4 User Manual

Page 921

Advertising
background image

Chapter 30

Installing and Creating Macros

921

bgRed, bgGreen, bgBlue, 0, 0

);
Select1 = Select(keepAspect, Resize1, SetBGColor1, 0, 0);
return Select1;

}

The ui file looks like this:

nuiPushMenu(“Tools”);

nuiPushToolBox(“Transform”);

nuiToolBoxItem(“@VidResize”,VidResize());

nuiPopToolBox();

nuiPopMenu();

The only tricky portions in the macro so far are the Select function, and the logic to
choose the height. When the branch of Select equals 1, the first image input is passed
through. When it equals 2, the second branch is fed through. The keepAspect
parameter is connected to Select to choose the branch you want. The other tricky
portion is the height logic, the first line of the macro body. It declares an internal
variable (it cannot be seen outside the macro) named yRes. It tests vidFormat to see if it
equals 0. If so, it sets yRes to equal 486, the height of an NTSC image. Otherwise, it sets
yRes to 576, the standard PAL image height.

Setting Slider Ranges

The first inconvenience about the macro, when used in the interface, is that the
keepAspect slider goes from 0 to 1. The values you want are 1 or 2. Since you do not
want to have to manually enter the format, it is easier to set the slider range from 1 to
2. This is done in the ui file VidResizeUI.h. To find the format, see “

Using Parameters

Controls Within Macros

” on page 379. If you are reading this document electronically,

you can copy and paste the command from the document into the text file.

To set the slider range:

1

Load the ui/VidResizeUI.h file into the text editor.

2

Add the nuiDefSlider function to set a slider range:

nuiPushMenu(“Tools”);

nuiPushToolBox(“Transform”);

nuiToolBoxItem(“@VidResize”,VidResize());

nuiPopToolBox();

nuiPopMenu();
nuiDefSlider(“VidResize.keepAspect”, 1, 2);

The word “VidResize” of VidResize.keepAspect indicates that you only want to modify
the keepAspect slider in the VidResize function. If you do not specify this, for example,
you just have nuiDefSlider(“keepAspect”, 1, 2); and it tries to apply that slider range to all
parameters named keepAspect, no matter what function they are in.

3

Save VidResizeUI.h and start Shake again.

4

Create the VidResize node (there is no need to test it on an image).

Advertising