Adobe 23101764 Scripting Guide - Page 95

Color objects

Page 95 highlights

Scripting Photoshop 3 Color objects • 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; Photoshop CS Scripting Guide 91

  • 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
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 speci
c 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;