Adobe 65014912 Manual page 70

Photoshop cs4 extended
Table of Contents

Advertisement

C
3: Scripting Photoshop
HAPTER
JS
To select an area and apply a wave filter to it:
1. Type the following code into the script file
original preferences:
//create new variables to contain doc width and height
//convert inches to pixels by multiplying the number of inches by
//the resolution (which equals number of pixels per inch)
docWidthInPixels = docWidthInInches * resolution
docHeightInPixels = docHeightInInches * resolution
//use the rasterize method of the artLayer class
newTextLayer.rasterize(RasterizeType.TEXTCONTENTS)
//create a variable to contain the coordinate values
//for the selection object
selRegion = Array(Array(0, 0),
Array(docWidthInPixels / 2, 0),
Array(docWidthInPixels / 2, docHeightInPixels),
Array(0, docHeightInPixels),
Array(0, 0))
//use the select method of the selection object
//to create an object and give it the selRegion values
//as coordinates
docRef.selection.select(selRegion)
newTextLayer.applyWave(1, 1, 100, 5, 10, 100, 100,
WaveType.SINE, UndefinedAreas.WRAPAROUND, 0)
2. Save the script, and then open Photoshop and select the script from the Scripts menu (choose File >
Script > HelloWorldDoc).
3. After viewing the document in Photoshop, close Photoshop without saving the document.
N
: Look up the following classes in the Adobe Photoshop CS4 JavaScript Scripting Reference, or in the
OTE
ExtendScript Object Model Viewer to see if you understand how you used them in this script:
ArtLayer
rasterize()
RasterizeType
JavaScripts.
applyWave()
method. Notice that the
constant. Constants are always depicted in upper case letters in Photoshop
method
just above the statements that restore
HelloWorldDoc
RasterizeType.TEXTCONTENTS
Advanced Scripting 70
argument uses the

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents