Apple Shake 4 User Manual
Page 933
Chapter 30
Installing and Creating Macros
933
Text Manipulation V: Extracting Part of a String
This function can be used to extract the file name from a FileOut or FileIn node so you
can print it on a slate. Use it in a Text function.
const char *getBaseFilename(const char *fileName)
{
extern const char * strrchr(const char *, char);
const char *baseName = strrchr(fileName, ’/’);
return baseName ? baseName+1 : fileName;
}
To use it, place a line in the text parameter of a Text function, such as:
{getBaseFilename(FileIn1.imageName)}
Tiling Example: TileExample
This allows you to take an image and tile it into rows and columns, similar to the Tile
node in the Other tab. However, this one also randomly moves each tile, as well as scales
the tiles down. The random movement is generated with the turbulence function (see
Chapter 31, “
,” on page 935). Because of this, it is less efficient
than the Tile function, which can be viewed in the
image TileExample(
image In=0,
int xTile=3,
int yTile=3,
float angle=0,
float xScale=1,
float yScale=1,
float random=30,
float frequency=10
)
{
result = Black(In.width, In.height, In.bytes);
curve float xFactor=(In.width/xTile)*.5;
curve float yFactor=(In.height/yTile)*.5;
for (int rows=1; rows<=yTile; ++rows){
for (int cols=1; cols<=xTile; ++cols){
Move2D1 = Move2D(In,
-width/2+xFactor+((cols-1)*xFactor*2)+
(turbulence(time+(cols+1)*(rows+1),frequency)-.5)*random,
-height/2+yFactor+((rows-1)*yFactor*2)+
(turbulence(time+(cols+1)/(rows+1),frequency)-.5)*random,
angle, 1,
1.0/xTile*xScale, 1.0/yTile*yScale
);
result=Over(Move2D1,result);
}
}
return result;