Adobe 23101764 Scripting Guide - Page 47
Displaying Colored Text
UPC - 718659340025
View all Adobe 23101764 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 47 highlights
Scripting Photoshop 3 Advanced Scripting Displaying Colored Text Having generated a default document, you can now display colored text. To do so, first set a local reference to the current document. Then create a SolidColor object and assign RGB color values to it. After defining the text for the current layer, create an art layer of type TEXT. NOTE: For a complete listing of all JavaScript properties, methods and constants (such as TEXT), please refer to the JavaScript Reference Guide, included as a separate document with Photoshop CS. Next, set the text, position, size and color of the text layer. The content of the text layer is the expression "Hello, World!". Notice that the position property of the text layer is an array whose values were chosen to roughly center the text in the dialog. A relatively large font size was chosen to increase the visibility of the text message. The color property is the SolidColor object created earlier, whose function is to display text in red. docRef = app.activeDocument; textColor = new SolidColor; textColor.rgb.red = 255; textColor.rgb.green = 0; textColor.rgb.blue = 0; helloWorldText = "Hello, World!"; newTextLayer = docRef.artLayers.add(); newTextLayer.kind = LayerKind.TEXT; newTextLayer.textItem.contents = helloWorldText; newTextLayer.textItem.position = Array(0.75, 1); newTextLayer.textItem.size = 36; newTextLayer.textItem.color = textColor; This code snippet outputs "Hello, World!" in red. Photoshop CS Scripting Guide 43