Adobe 23102480 Scripting Guide - Page 52
Comparing Colors, Getting a Web Safe Color, Adobe Photoshop CS3 AppleScript Scripting Reference
UPC - 883919080222
View all Adobe 23102480 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 52 highlights
Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 52 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 CS3 AppleScript Scripting Reference or in the Photoshop CS3 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 Look up the following in the Adobe Photoshop CS3 Visual Basic Scripting Reference, or in the Visual Basic Object Browser: ● model and cmyk as properties of the SolidColor object JS This example uses the foregroundColor property of the Application object to get the original color to be converted. The cmyk property of the SolidColor object that foregroundColor refers to provides a way to access the cmyk equivalent of the rgb color. var someColor = foregroundColor.cmyk Look up the following in the Adobe Photoshop CS3 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer: ● cmyk as a property of the SolidColor object ● foregroundColor as a property of the Application object Comparing Colors Using the equal colors (IsEqual/isEqual) command, you can compare colors. The following statements return true if the foreground color is visually equal to background color. ● AS: if equal colors foreground color with background color then ● VBS: If (appRef.ForegroundColor.IsEqual(appRef.BackgroundColor)) Then ● JS: if (app.foregroundColor.isEqual(backgroundColor)) Getting a Web Safe Color To convert a color to a web safe color use the web safe color command on AppleScript and the NearestWebColor/nearestWebColor property of the SolidColor object for VBScript and JavaScript.