Apple Shake 4 User Manual

Page 930

Advertising
background image

930

Chapter 30

Installing and Creating Macros

shake uboat.iff -autofit 166 w

This calculates an image that is 166 x 125 pixels in size. It is not necessary to calculate
the height on your own.

Here is the code:

image AutoFit(image img=0, int size=166, int sizeIs=1)
{

curve w=0;
curve h=1;
return Resize(img,

sizeIs ? size*width/height :size ,
sizeIs ? size : size*height/width

);

}

The first line creates the parameters. Note that calculate is expecting an integer. The
next two lines assign a value to both w and h. This way, the user can type in 0 or 1 to
calculate width or height, or enter w or h, which is easier to remember. Since Shake
assigns values to w and h, it is able to determine what axis to calculate. The Resize
function uses embedded if/then statements to test the sizeIs parameter. Also, you do
not change the value of w or h during processing, so they are not declared as the curve
int type of data.

Text Manipulation I: RandomLetter

This function generates a random letter up to a certain frame, at which point a static
letter appears. You can select the color, switch frame, position, and size of the letter, as
well as the font. This function uses the standard C stringf function to pick a random
letter, and assigns it to the variable rdLetter. This is pumped into the Text function,
which uses a conditional expression to evaluate if the current time is before the
staticFrame time (set to frame 10 by default).

image RandomLetter(

int width=720,
int height=486,
int bytes=1,
const char * letter=“A”,
int staticFrame=10,
float seed=time,
const char * font=“Courier”,
float xFontScale=100,
float yFontScale=100,
float xPos=width/2,
float yPos=height/2,
float red=1,
float green=1,
float blue=1,
float alpha=1
)

Advertising