Adobe 23101335 Scripting Guide - Page 77

Color objects, 3.14.1 Setting a Color

Page 77 highlights

Scripting Photoshop 3 Color objects 3.14 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.14.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; SolidColor class Visual Basic and JavaScript have an additional class called the SolidColor class. This class contains a property for each color model. To use this object, first create an instance of a SolidColor object, then set its appropriate color model properties. Once a color model has been assigned to a SolidColor object, the SolidColor object cannot be reassigned to a different color model. Below are examples on how to create a SolidColor object and set its CMYK property. VB: Dim solidColor As Photoshop.SolidColor Set solidColor = CreateObject("Photoshop.SolidColor") solidColor. CMYK.Cyan = 20 solidColor.CMYK.Magenta = 90 solidColor.CMYK.Yellow = 50 Photoshop 7.0 Scripting Guide 77

  • 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

Photoshop 7.0 Scripting Guide
77
Scripting Photoshop
Color objects
3
3.14 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.14.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;
SolidColor class
Visual Basic and JavaScript have an additional class called the
SolidColor
class. This class
contains a property for each color model. To use this object, first create an instance of a
SolidColor
object, then set its appropriate color model properties. Once a color model has
been assigned to a
SolidColor
object, the
SolidColor
object cannot be reassigned to a
different color model. Below are examples on how to create a
SolidColor
object and set its
CMYK property.
VB:
Dim solidColor As Photoshop.SolidColor
Set solidColor = CreateObject("Photoshop.SolidColor")
solidColor. CMYK.Cyan = 20
solidColor.CMYK.Magenta = 90
solidColor.CMYK.Yellow = 50