Adobe 23101764 Scripting Guide - Page 56

Notice that the position property of the text layer is an array whose values were chosen

Page 56 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 layer. NOTE: For a complete listing of all AppleScript properties, methods and constants (such as text layer), please refer to the AppleScript Reference Guide, included as a separate document with Photoshop CS. Next, set the text, position, size and color of the text layer. The contents 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 theTextColor created earlier, whose function is to display text in red. set theDocRef to the current document set theTextColor to {class:RGB color, red:255, green:0, blue:0} set theTextLayer to make new art layer in theDocRef with¬ properties {kind:text layer} set contents of text object of theTextLayer to "Hello, World!" set size of text object of theTextLayer to 36 set position of text object of theTextLayer to {0.75, 1} set stroke color of text object of theTextLayer to theTextColor This code snippet outputs "Hello, World!" in red. Photoshop CS Scripting Guide 52

  • 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
52
Scripting Photoshop
Advanced Scripting
3
Displaying Colored Text
Having generated a default document, you can now display colored text. To do so,
rst set a
local reference to the current document. Then create a SolidColor object and assign RGB color
values to it. After de
ning the text for the current layer, create an art layer of type
text
layer
.
N
OTE
:
For a complete listing of all AppleScript properties, methods and constants (such as
text layer
), please refer to the AppleScript Reference Guide, included as a separate
document with Photoshop CS.
Next, set the text, position, size and color of the text layer. The contents 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
theTextColor
created earlier, whose
function is to display text in red.
set theDocRef to the current document
set theTextColor to {class:RGB color, red:255, green:0, blue:0}
set theTextLayer to make new art layer in theDocRef with¬
properties {kind:text layer}
set contents of text object of theTextLayer to "Hello, World!"
set size of text object of theTextLayer to 36
set position of text object of theTextLayer to {0.75, 1}
set stroke color of text object of theTextLayer to theTextColor
This code snippet outputs "Hello, World!" in red.