Adobe 23101764 Scripting Guide - Page 88

Stroking the selection border, Inverting selections, Expand, contract and feather selections

Page 88 highlights

Scripting Photoshop 3 Selections 3.12.2 Stroking the selection border The following examples show how to stroke the boundaries around the current selection and set the stroke color and width. 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 VB: selRef.Stroke strokeColor, Width:=5, Location:=psInsideStroke, _ mode:=psVividLightBlend, Opacity:=75, _ PreserveTransparency:=False JS: app.activeDocument.selection.stroke (strokeColor, 2, StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75, false); IMPORTANT: The transparency parameter cannot be used for background layers. 3.12.3 Inverting selections When you invert a selection, you are masking the selection so you can work on the rest of the document, layer or channel while protecting the selection. Here's how to invert the current selection: AS: invert selection of current document VB: selRef.Invert JS: selRef.invert(); 3.12.4 Expand, contract and feather selections These three commands are used to change the size of the selection. The values are passed in ruler units, the values of which are stored in Photoshop preferences and can be changed by your scripts. Feathering a selection will smooth its corners by the specified number of units while expand and contract will grow and shrink the selection. If your ruler units are set to pixels, then the following examples will expand, contract and feather by five pixels. See section 3.6.3, "Changing ruler and type units" on page 61 for examples of how to change ruler units. Photoshop CS Scripting Guide 84

  • 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
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
84
Scripting Photoshop
Selections
3
3.12.2
Stroking the selection border
The following examples show how to stroke the boundaries around the current selection and
set the stroke color and width.
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
VB:
selRef.Stroke strokeColor, Width:=5, Location:=psInsideStroke, _
mode:=psVividLightBlend, Opacity:=75, _
PreserveTransparency:=False
JS:
app.activeDocument.selection.stroke (strokeColor, 2,
StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75,
false);
IMPORTANT:
The transparency parameter cannot be used for background layers.
3.12.3
Inverting selections
When you invert a selection, you are masking the selection so you can work on the rest of the
document, layer or channel while protecting the selection. Here’s how to invert the current
selection:
AS:
invert selection of current document
VB:
selRef.Invert
JS:
selRef.invert();
3.12.4
Expand, contract and feather selections
These three commands are used to change the size of the selection. The values are passed in
ruler units, the values of which are stored in Photoshop preferences and can be changed by
your scripts. Feathering a selection will smooth its corners by the speci
ed number of units
while expand and contract will grow and shrink the selection.
If your ruler units are set to pixels, then the following examples will expand, contract and
feather by
ve pixels. See section
3.6.3, “Changing ruler and type units” on page 61
for
examples of how to change ruler units.