
Photoshop CS Scripting Guide
91
Scripting Photoshop
Color objects
3
•
spot color channel (psSpotColorChannel, ChannelType.SPOTCOLOR)
.
The examples below show how to create a new masked area channel.
AS:
make new channel in current document with properties ¬
{kind:masked area channel }
VB:
Set channelRef = docRef.Channels.Add
channelRef.Kind = psMaskedAreaChannel
JS:
var channelRef = docRef.channels.add();
channelRef.kind = ChannelType.MASKEDAREA;
3.15 Color objects
From scripting you can use the same range of colors that are available from the Photoshop user
interface. Each has its own set of properties, which are specific to the color. For example, the
RGB color class contains three properties — red, blue and green.
3.15.1 Setting a Color
Here’s how to set the foreground color to a CMYK color in AppleScript.
set foreground color to {class:CMYK color, cyan:20.0, ¬
magenta:90.0, yellow:50.0, black:50.0}
Because you can use any color model, you could also write the following to set the foreground
to an RGB color.
set foreground color to { class:RGB color, red:80.0, green:120.0,¬
blue:57.0 }
In Visual Basic and JavaScript, the
SolidColor
object handles all colors. To set the
foreground color you should create a
SolidColor
object, set its color model by assigning the
color model values and then set the foreground color to the solid color. Here’s how:
VB:
solidColor = CreateObject("Photoshop.SolidColor")
appRef.ForegroundColor = solidColor
JS:
var solidColor = new SolidColor();
foregroundColor = solidColor;