Apple Shake 4 User Manual
Page 931

Chapter 30
Installing and Creating Macros
931
{
curve string rdLetter = stringf(“%c”,
’A’+(int)floor(rnd1d(seed,time)*26));
return Text(
width, height, bytes,
time < staticFrame?“{rdLetter}”:“{letter}”,
font,
xFontScale, yFontScale, 1, xPos, yPos,
0, 2, 2, red, green, blue, alpha, 0, 0, 0, 45
);
}
Text Manipulation II: RadioButton
This is an excerpt from the RadioButton function that is used to generate radio buttons
for the interface. The radio button code requires four icons to support it: name.on.nri,
name.on.focus.nri, name.off.nri, and name.off.focus.nri. Since it is tedious to write out
four separate files, automatically change the file extensions over time with this excerpt
from the macro:
image RadioButton(
const char *text=“linear”,
...
string fileName=text,
string filePath=“/Documents/Shake/icons/ux/radio/”,
int branch=time,
..
)
{
curve string fileState =
branch == 1 ? “.on.nri” :
branch == 2 ? “.on.focus.nri” :
branch == 3 ? “.off.nri” : “.off.focus.nri”;
curve string fileOutName = filePath + “/”+
fileName + fileState;
...
return FileOut(Saturation1, fileOutName);
Since you typically calculate this with a command such as:
shake -radio “HelloWorld” -t 1-4
it generates HelloWorld.on.nri at frame 1, HelloWorld.on.focus.nri at frame 2,
HelloWorld.off.nri at frame 3, and HelloWorld.off.focus.nri at frame 4.