Adobe 23101764 Scripting Guide - Page 96

Dim solidColor As Photoshop.SolidColor

Page 96 highlights

Scripting Photoshop 3 Color objects 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 for creating 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 solidColor.CMYK.Black = 50 JS: var solidColor = new SolidColor(); solidColor.cmyk.cyan = 20; solidColor.cmyk.magenta = 90; solidColor.cmyk.yellow = 50; solidColor.cmyk.black = 50; Hex values An RGB color can also be represented as a hex value. The hexadecimal value is used to represent the three colors of the RGB model. The hexadecimal value contains three pairs of numbers which when read from left to right, represent the red, blue and green colors. In AppleScript, the hex value is represented by the hex value string property in class RGB hex color, and you use the convert color command described below to retrieve the hex value. In Visual Basic and JavaScript, the RGBColor object has a string property called HexValue/hexValue. Photoshop CS Scripting Guide 92

  • 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
92
Scripting Photoshop
Color objects
3
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,
rst 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 for creating 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
solidColor.CMYK.Black = 50
JS:
var solidColor = new SolidColor();
solidColor.cmyk.cyan = 20;
solidColor.cmyk.magenta = 90;
solidColor.cmyk.yellow = 50;
solidColor.cmyk.black = 50;
Hex values
An RGB color can also be represented as a hex value. The hexadecimal value is used to
represent the three colors of the RGB model. The hexadecimal value contains three pairs of
numbers which when read from left to right, represent the red, blue and green colors.
In AppleScript, the hex value is represented by the
hex value
string property in class
RGB
hex color
, and you use the
convert color
command described below to retrieve the hex
value.
In Visual Basic and JavaScript, the RGBColor object has a string property called
HexValue/hexValue
.