
Photoshop 7.0 Scripting Guide
71
Scripting Photoshop
Selections
3
Dim originalRulerUnits As Photoshop.PsUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psPixels
Dim selRef As Photoshop.Selection
Set selRef = appRef.ActiveDocument.Selection
selRef.Expand 5
selRef.Contract 5
selRef.Feather 5
'Rem restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
JS:
// remember unit settings; and set to pixels
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var selRef = activeDocument.selection
selRef.expand( 5 );
selRef.contract( 5 );
selRef.feather( 5 );
// restore unit setting
preferences.rulerUnits = originalRulerUnits;
3.11.5 Filling a selection
You can fill a selection either will a color or a history state. To fill with a color:
AS:
fill selection of current document with contents ¬
{class: RGB color, red:255, green:0, blue:0} blend mode ¬
vivid light opacity 25 without preserving transparency
VB:
Set fillColor = CreateObject("Photoshop.SolidColor")
fillColor.RGB.Red = 255
fillColor.RGB.Green = 0
fillColor.RGB.Blue = 0
selRef.Fill fillColor mode:=psVividLightBlend, _
Opacity:=25, PreserveTransparency:=False