Apple Shake 4 User Manual
Page 932
932
Chapter 30
Installing and Creating Macros
Text Manipulation III: A Banner
This little trick takes a string of letters and prints it, one letter at a time. It declares a
variable within the string section of a Text node:
Text1 = Text(720, 486, 1,
{{ string logo = “My Logo Here”;
stringf(“%c”, logo[(int) clamp(time-1, 0,strlen(logo))])
}},
“Courier”, 100, xFontScale, 1, width/2, height/2,
0, 2, 2, 1, 1, 1, 1, 0, 0, 0, 45);
This uses strlen to determine the length of the string and extract the letter that
corresponds to the current frame.
Text Manipulation IV: Text With a Loop to Make a Clock Face
This eager little example lays out a clock face. A for loop is used to count from 1 to 12,
and prints the number into a Text function with a stringf function. (You should just be
able to print the value of count with {count}, but it doesn’t work. Go figure.) The cosd
and sind functions are also used to calculate the position of the number on the clock
face. Keep in mind that zero degrees in Shake points east, as it does in all Cartesian
math. The falloffRadius serves no purpose in the function except to complete the
onscreen control set to give a center and a radius widget:
image Clock(
image In=0,
float xCenter=width/2,
float yCenter=height/2,
float radius=150,
float falloffRadius=0
)
{
NumComp=Black(In.width,In.height,1);
for (int count=1;count<=12;++count)
{
NumComp = Over(
Text(In.width, In.height, 1, {{ stringf(“%d”,count) }},
“Courier”, radius*.25, xFontScale, 1,
cosd(60+(count-1)*-30)*radius+xCenter,
sind(60+(count-1)*-30)*radius+yCenter,
0, 2, 2, 1, 1, 1, 1, 0, 0, 0, 45),
NumComp
);
}
return Over(NumComp,In);
}