Adobe 23102480 Scripting Guide - Page 43

Inverting Selections, Expanding, Contracting, and Feathering Selections, Filling a Selection

Page 43 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 43 JS strokeColor = new solidColor strokeColor.cmyk.cyan = 20 strokeColor.cmyk.magenta = 50 strokeColor.cmyk.yellow = 30 strokeColor.cmyk.black = 0 app.activeDocument.selection.stroke (strokeColor, 2, StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75, false) Inverting Selections You can use the invert (Invert/invert()) command of the Selection object to a selection so you can work on the rest of the document, layer or channel while protecting the selection. ASinvert selection of current document VBSselRef.Invert JSselRef.invert() Expanding, Contracting, and Feathering Selections You can change the size of a selected area using the expand, contract, and feather commands. The values are passed in the ruler units stored in Photoshop CS3 preferences and can be changed by your scripts. If your ruler units are set to pixels, then the following examples will expand, contract, and feather by five pixels. See section 'Setting Application Preferences' on page 30 for examples of how to change ruler units. AS expand selection of current document by pixels 5 contract selection of current document by pixels 5 feather selection of current document by pixels 5 VBS Dim selRef Set selRef = appRef.ActiveDocument.Selection selRef.Expand 5 selRef.Contract 5 selRef.Feather 5 JS var selRef = app.activeDocument.selection selRef.expand( 5 ) selRef.contract( 5 ) selRef.feather( 5 ) Filling a Selection You can fill a selection either with a color or a history state. To fill with a color:

  • 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
43
JS
strokeColor = new solidColor
strokeColor.cmyk.cyan = 20
strokeColor.cmyk.magenta = 50
strokeColor.cmyk.yellow = 30
strokeColor.cmyk.black = 0
app.activeDocument.selection.stroke (strokeColor, 2,
StrokeLocation.OUTSIDE, ColorBlendMode.VIVIDLIGHT, 75,
false)
Inverting Selections
You can use the
invert (Invert/invert())
command of the
Selection
object to a selection so you
can work on the rest of the document, layer or channel while protecting the selection.
AS
invert selection of current document
VBS
selRef.Invert
JS
selRef.invert()
Expanding, Contracting, and Feathering Selections
You can change the size of a selected area using the expand, contract, and feather commands.
The values are passed in the ruler units stored in Photoshop CS3 preferences and can be changed by your
scripts. If your ruler units are set to pixels, then the following examples will expand, contract, and feather
by five pixels. See section
‘Setting Application Preferences’ on page 30
for examples of how to change
ruler units.
AS
expand selection of current document by pixels 5
contract selection of current document by pixels 5
feather selection of current document by pixels 5
VBS
Dim selRef
Set selRef = appRef.ActiveDocument.Selection
selRef.Expand 5
selRef.Contract 5
selRef.Feather 5
JS
var selRef = app.activeDocument.selection
selRef.expand( 5 )
selRef.contract( 5 )
selRef.feather( 5 )
Filling a Selection
You can fill a selection either with a color or a history state.
To fill with a color: