Adobe 65048332 Scripting Guide - Page 52
Solid color classes, Using hex values for RGB color, Getting and converting colors
View all Adobe 65048332 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 52 highlights
CHAPTER 3: Scripting Photoshop Solid color classes The solid color classes available in Photoshop are illustrated below. Color Classes Solid Color Working with color objects 52 RGB Color CMYK Color Gray Color HSB Color Lab Color No Color Using hex values for RGB color You can express RGB colors as hex (or hexadecimal) values. A hex value contains three pairs of numbers which represent red, blue and green (in that order). 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 VBScript and JavaScript, the RGBColor object has a string property called HexValue/hexValue. Getting and converting colors The following examples convert an RGB color to its CMYK equivalent. AS The following script, which assumes an RGB color model, gets the foreground color and then uses the convert command of the color class to convert the color to its CMYK equivalent. get foreground color convert color foreground color to CMYK Look up the following in the Adobe Photoshop CS5 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary: ➤ In the "Objects" section, the foreground color property of the class application ➤ In the "Commands" section, convert VBS The following script uses an If Then statement and the model property of the SolidColor object to determine the color model in use. The If Then statement returns a SolidColor object; if it returns an RGB object, the cmyk property of the SolidColor object then allows you to access the color with its CMYK equivalent. Dim someColor If (someColor.model = 2) Then someColor.cmyk 'someColor.model = 2 indicates psColorModel --> 2 (psRGBModel) End If