Adobe 23101764 Scripting Guide - Page 52

Set textColor = New Photoshop.SolidColor

Page 52 highlights

Scripting Photoshop 3 Advanced Scripting 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. Set docRef = app.ActiveDocument Set textColor = New Photoshop.SolidColor textColor.RGB.Red = 255 textColor.RGB.Green = 0 textColor.RGB.Blue = 0 Set newTextLayer = docRef.ArtLayers.Add() newTextLayer.Kind = Photoshop.PsLayerKind.psTextLayer newTextLayer.TextItem.Contents = helloWorldStr newTextLayer.TextItem.Position = Array(0.75, 1) newTextLayer.TextItem.Size = 36 newTextLayer.TextItem.Color = textColor This code snippet outputs "Hello, World!" in red. Applying a Wave Filter Now that text displays on your document, you're ready to apply some special effects. First, redefine the width and height of the document in pixels. Additionally, convert the text layer to pixels -- we do this because text is a vector graphic and we need a bitmap in order to manipulate the image. Next create an array to specify the area to be selected for image manipulation. Notice that the array of points begins at the top left corner of the dialog and extends half way across the document. Other array values define vertical positioning. With the width and height of the array thus defined, select the left side of the document. "Ants marching up the page" delimit the area selected. Photoshop CS Scripting Guide 48

  • 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
48
Scripting Photoshop
Advanced Scripting
3
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.
Set docRef = app.ActiveDocument
Set textColor = New Photoshop.SolidColor
textColor.RGB.Red = 255
textColor.RGB.Green = 0
textColor.RGB.Blue = 0
Set newTextLayer = docRef.ArtLayers.Add()
newTextLayer.Kind = Photoshop.PsLayerKind.psTextLayer
newTextLayer.TextItem.Contents = helloWorldStr
newTextLayer.TextItem.Position = Array(0.75, 1)
newTextLayer.TextItem.Size = 36
newTextLayer.TextItem.Color = textColor
This code snippet outputs "Hello, World!" in red.
Applying a Wave Filter
Now that text displays on your document, you’re ready to apply some special effects. First, re-
de
ne the width and height of the document in pixels. Additionally, convert the text layer to
pixels -- we do this because text is a vector graphic and we need a bitmap in order to
manipulate the image.
Next create an array to specify the area to be selected for image manipulation. Notice that the
array of points begins at the top left corner of the dialog and extends half way across the
document. Other array values de
ne vertical positioning.
With the width and height of the array thus de
ned, select the left side of the document. "Ants
marching up the page" delimit the area selected.