
Adobe Photoshop CS3
JavaScript Scripting Reference
JavaScript Object Reference 140
Sample Script
The following creates a path in three segments: two diagonal lines that form a
V
, and a curved line above
the
V
that makes it look like a 2D ice cream cone.
Paths.jsx
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CS3 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
// first close all the open documents
while (app.documents.length) {
app.activeDocument.close()
}
// create a document to work with
var docRef = app.documents.add(5000, 7000, 72, "Simple Line")
//line 1--it’s a straight line so the coordinates for anchor, left, and right
//for each point have the same coordinates
var lineArray = new Array()
lineArray[0] = new PathPointInfo
lineArray[0].kind = PointKind.CORNERPOINT
makeClippingPath
([flatness])
number (double)
Makes this
pathItem
object
the clipping path for this
document; the optional
parameter tells the PostScript
printer how to approximate
curves in the path (0.2 - 100).
makeSelection
([feather]
[, antiAlias]
[, operation])
number (double)
boolean
SelectionType
Makes a
selection
object,
whose border is the path, from
this
pathItem
object (
feather
:
0.0 - 250.0 in pixels).
Note:
See
Selection
.
remove
()
Deletes this
pathItem
object.
select
()
Makes this
pathItem
object
the active or selected
pathItem
object.
strokePath
([tool]
[, simulatePressure])
ToolType
boolean
Strokes the path with the
specified information.
Method
Parameter Type
Returns
What it does (Continued)