Photoshop CS Scripting Guide
44
Scripting Photoshop
Advanced Scripting
3
Applying a Wave Filter
Now that text displays on your document, you’re ready to apply some special effects. First, re-
define the width and height of the document in pixels. Additionally, convert the text layer to
pixels -- we do this because text is a vector graphic and we need a bitmap in order to
manipulate the image.
Next create an array to specify the area to be selected for image manipulation. Notice that the
array of points begins at the top left corner of the dialog and extends half way across the
document. Other array values define vertical positioning.
With the width and height of the array thus defined, select the left side of the document. "Ants
marching up the page" delimit the area selected.
You can now apply a wave filter to the selection. A truncated sin curve carries the text along
for a roller-coaster-like ride.
docWidthInPixels = docWidthInInches * resolution;
docHeightInPixels = docHeightInInches * resolution;
newTextLayer.rasterize(RasterizeType.TEXTCONTENTS);
selRegion = Array(Array(0, 0),
Array(docWidthInPixels / 2, 0),
Array(docWidthInPixels / 2, docHeightInPixels),
Array(0, docHeightInPixels),
Array(0, 0));
docRef.selection.select(selRegion);
newTextLayer.applyWave(1, 1, 100, 5, 10, 100, 100,
WaveType.SINE, UndefinedAreas.WRAPAROUND, 0);
This code snippet manipulates and bends the text on the left side of the document.