Adobe 23102480 Scripting Guide - Page 42

Stroking the Selection Border

Page 42 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 42 ➤ The following examples assume that the ruler units have been set to pixels and create a selection by: 1. Creating a variable to hold a new document that is 500 x 500 pixels in size. 2. Creating a variable to hold the coordinates that describe the selected area (that is, the Selection object). 3. Adding an array as the selection variable's value. 4. Using the Document object's selection property, and the Selection object's select command to select an area. The area's coordinates are the selection variable's values. AS set docRef to make new document with properties {height:500, width:500} set shapeRef to {{0, 0}, {0, 100}, {100, 100}, {100, 0}} select current document region shapeRef VBS DocRef = appRef.Documents.Add ShapeRef = Array(Array(0, 0), Array(0, 100), Array(100,100), Array(100,0)) docRef.Selection.Select ShapeRef JS var docRef = app.documents.add(500, 500) var shapeRef = [ [0,0], [0,100], [100,100], [100,0] ] docRef.selection.select(shapeRef) Stroking the Selection Border The following examples use the stroke (Stroke/stroke()) command of the Selection object to stroke the boundaries around the current selection and set the stroke color and width. Note: The transparency parameter cannot be used for background layers. AS stroke selection of current document using color ¬ {class:CMYK color, cyan:20, magenta:50, yellow:30, black:0} ¬ width 5 location inside blend mode vivid light opacity 75 ¬ without preserving transparency VBS Set strokeColor = CreateObject ("Photoshop.SolidColor") strokeColor.CMYK.Cyan = 20 strokeColor.CMYK.Magenta = 50 strokeColor.CMYK.Yellow = 30 strokeColor.CMYK.Black = 0 appRef.ActiveDocument.Selection.Stroke strokeColor, 5, 1, 15, 75, False

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Scripting Photoshop CS3
42
The following examples assume that the ruler units have been set to pixels and create a selection
by:
1.
Creating a variable to hold a new document that is 500 x 500 pixels in size.
2.
Creating a variable to hold the coordinates that describe the selected area (that is, the
Selection
object).
3.
Adding an array as the selection variable’s value.
4.
Using the
Document
object’s
selection
property, and the
Selection
object’s
select
command to
select an area. The area’s coordinates are the selection variable’s values.
AS
set docRef to make new document with properties {height:500, width:500}
set shapeRef to {{0, 0}, {0, 100}, {100, 100}, {100, 0}}
select current document region shapeRef
VBS
DocRef = appRef.Documents.Add
ShapeRef = Array(Array(0, 0), Array(0, 100), Array(100,100), Array(100,0))
docRef.Selection.Select ShapeRef
JS
var docRef = app.documents.add(500, 500)
var shapeRef = [
[0,0],
[0,100],
[100,100],
[100,0]
]
docRef.selection.select(shapeRef)
Stroking the Selection Border
The following examples use the
stroke (Stroke/stroke())
command of the
Selection
object to
stroke the boundaries around the current selection and set the stroke color and width.
Note:
The transparency parameter cannot be used for background layers.
AS
stroke selection of current document using color ¬
{class:CMYK color, cyan:20, magenta:50, yellow:30, black:0} ¬
width 5 location inside blend mode vivid light opacity 75 ¬
without preserving transparency
VBS
Set strokeColor = CreateObject ("Photoshop.SolidColor")
strokeColor.CMYK.Cyan = 20
strokeColor.CMYK.Magenta = 50
strokeColor.CMYK.Yellow = 30
strokeColor.CMYK.Black = 0
appRef.ActiveDocument.Selection.Stroke strokeColor, 5, 1, 15, 75, False