Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 82

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
JS
To create and specify details in a text item:
1. Type the following code into the
statements that restore original preferences.
//create a reference to the active document
docRef = app.activeDocument
//create a variable named textColor
//create a SolidColor object whose color is red
//assign the object to textColor
textColor = new SolidColor
textColor.rgb.red = 255
textColor.rgb.green = 0
textColor.rgb.blue = 0
helloWorldText = "Hello, World!"
//create a variable named newTextLayer
//use the add() method of the artLayers class to create a layer object
//assign the object to newTextLayer
newTextLayer = docRef.artLayers.add()
//use the kind property of the artLayer class to make the layer a text layer
newTextLayer.kind = LayerKind.TEXT
newTextLayer.textItem.contents = helloWorldText
newTextLayer.textItem.position = Array(0.75, 1)
newTextLayer.textItem.size = 36
newTextLayer.textItem.color = textColor
2. Save the script, and then open Photoshop CS2 and select the script from the Scripts menu (choose File
> Script > HelloWorldDoc). Be patient while Photoshop CS2 executes your commands one by one.
3. After viewing the document in Photoshop CS2, close Photoshop CS2 without saving the document.
Note:
Look up the following classes in the Adobe JavaScript Scripting Reference "Object Reference" chapter
to see if you understand how you used them in this script:
Applying a Wave Filter
In this section we'll apply a wave filter to the word Hello in our document. This entails the following steps:
Set the document width and height to pixels and then rasterize the text object in the Text Layer.
Note:
Because text is a vector graphic and cannot apply a wave filter to vector graphics, we must first
convert the image to a bitmap. Rasterizing converts mathematically defined vector artwork to
pixels. For more information on rasterizing, refer to Photoshop CS2 Help.
Select the area of the layer to which we want to apply the wave filter.
Note:
SolidColor
. Notice that the
ArtLayer
constant. Constants are always depicted in upper case letters in Photoshop CS2 JavaScripts.
See
Defining the Area of a Selection Object
script that accomplishes this task.
Photoshop CS2
script immediately before the commented
HelloWorldDoc
value of the kind property uses the
LayerKind.TEXT
Scripting Photoshop CS2
in order to understand the code within the
78
LayerKind

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents