Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 80

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
if (app.documents.length == 0)
app.documents.add(docWidthInInches, docHeightInInches, resolution)
//restore beginning preferences
app.preferences.rulerunits = startRulerUnits
app.preferences.typeunits = startTypeUnits
app.displayDialogs = startDisplayDialogs
2. Name the script
3. Open Photoshop CS2 and choose File > Scripts > HelloWorldDoc to run the script.
4. Choose Edit > Preferences > Units & Rulers to verify that your preferences have been returned to
your original settings.
5. After viewing the document in Photoshop CS2, close the document without saving it.
6. To prepare the script for the next section, comment the statements that restore the beginning
preferences by adding slashes as follows:
//app.preferences.rulerunits = startRulerUnits
//app.preferences.typeunits = startTypeUnits
7. Save the script.
Applying Color to a Text Item
In this section, we will add a layer to the
displays the text Hello, World! in red.
Before you begin, do the following:
Make sure Photoshop CS2 is closed.
Open the script file
AS
To create and specify details in a text item:
1. Type the following code into the
statements that restore original preferences.
--create a variable named theDocRef
--assign the current (active) document to it
set theDocRef to the current document
--create a variable that contains a color object of the RGB color class
--whose color is red
set theTextColor to {class:RGB color, red:255, green:0, blue:0}
--create a variable for the text layer, create the layer as an art layer object
--and use the kind property of the art layer object to make it a text layer
set theTextLayer to make new art layer in theDocRef with¬
properties {kind:text layer}
--Set the contents, size, position and color of the text layer
set contents of text object of theTextLayer to "Hello, World!"
set size of text object of theTextLayer to 36
set position of text object of theTextLayer to {0.75, 1}
Photoshop CS2
and save it in the Scripts folder.
HelloWorldDoc.jsx
HelloWorldDoc
in your script editor application.
HelloWorldDoc
HelloWorldDoc
script, then change the layer to a text object that
script immediately before the commented
Scripting Photoshop CS2
76

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs2

Table of Contents