Adobe 23102480 Scripting Guide - Page 66

Applying a Wave Filter, Defining the Area of a Selection Object

Page 66 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 66 Note: Look up the following classes in the Adobe Photoshop CS3 JavaScript Scripting Reference, or in the ExtendScript Object Model Viewer to see if you understand how you used them in this script: ● SolidColor ● ArtLayer. Notice that the LayerKind.TEXT value of the kind property uses the LayerKind constant. Constants are always depicted in upper case letters in Photoshop CS3 JavaScripts. Applying a Wave Filter In this section we'll apply a wave filter to the word Hello in our document. This entails the following steps: ● Set the document width and height to pixels and then rasterize the text object in the Text Layer. Note: Because text is a vector graphic and cannot apply a wave filter to vector graphics, we must first convert the image to a bitmap. Rasterizing converts mathematically defined vector artwork to pixels. For more information on rasterizing, refer to Photoshop CS3 Help. ● Select the area of the layer to which we want to apply the wave filter. Note: See Defining the Area of a Selection Object in order to understand the code within the script that accomplishes this task. ● Apply a wave filter to the selection. Note: The wave is a truncated sine curve. Defining the Area of a Selection Object To define the area of a selection object, we create an array of coordinates, or points specified in pixels within the document. The array indicates the coordinates that define the outside corners of a rectangular area that begins at the top left corner of the document and extends half way across the document. Note: You can define any number of points for a selected area. The number of coordinates determines the shape of the selection. The last coordinate defined must be the same as the first so that the area is a closed selection path. Note: See 'Photoshop CS3 Object Model' on page 9 for information on selection objects and other Photoshop CS3 objects. The array values in order are: ● Upper left corner of the selection: 0,0 ● 0 indicates the left-most column in the document. ● 0 indicates the top row in the document. ● Upper right corner of the selection: theDocWidthInPixels / 2, 0 ● theDocWidthInPixels / 2 indicates the column in the middle of the document; that is, the column whose coordinate is the total number of columns in the document divided by 2. Note: The value of theDocWidthInPixels is the total number of pixels that defines the document's horizontal dimension. Columns are arranged horizontally. ● 0 indicates the top row in the document. ● Lower right corner: theDocWidthInPixels / 2, theDocHeightInPixels ● theDocWidthInPixels / 2 indicates the middle of the document.

  • 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

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Scripting Photoshop CS3
66
Note:
Look up the following classes in the
Adobe Photoshop CS3 JavaScript Scripting Reference
, or in the
ExtendScript Object Model Viewer to see if you understand how you used them in this script:
SolidColor
ArtLayer
. Notice that the
LayerKind.TEXT
value of the kind property uses the
LayerKind
constant. Constants are always depicted in upper case letters in Photoshop CS3 JavaScripts.
Applying a Wave Filter
In this section we’ll apply a wave filter to the word
Hello
in our document. This entails the following steps:
Set the document width and height to pixels and then rasterize the text object in the Text Layer.
Note:
Because text is a vector graphic and cannot apply a wave filter to vector graphics, we must first
convert the image to a bitmap. Rasterizing converts mathematically defined vector artwork to
pixels. For more information on rasterizing, refer to Photoshop CS3 Help.
Select the area of the layer to which we want to apply the wave filter.
Note:
See
Defining the Area of a Selection Object
in order to understand the code within the script
that accomplishes this task.
Apply a wave filter to the selection.
Note:
The wave is a truncated sine curve.
Defining the Area of a Selection Object
To define the area of a selection object, we create an array of coordinates, or points specified in pixels
within the document. The array indicates the coordinates that define the outside corners of a rectangular
area that begins at the top left corner of the document and extends half way across the document.
Note:
You can define any number of points for a selected area. The number of coordinates determines the
shape of the selection. The last coordinate defined must be the same as the first so that the area is a
closed selection path.
Note:
See
‘Photoshop CS3 Object Model’ on page 9
for information on selection objects and other
Photoshop CS3 objects.
The array values in order are:
Upper left corner of the selection:
0,0
0
indicates the left-most column in the document.
0
indicates the top row in the document.
Upper right corner of the selection:
theDocWidthInPixels / 2, 0
theDocWidthInPixels / 2
indicates the column in the middle of the document; that is, the
column whose coordinate is the total number of columns in the document divided by 2.
Note:
The value of
theDocWidthInPixels
is the total number of pixels that defines the document’s
horizontal dimension. Columns are arranged horizontally.
0
indicates the top row in the document.
Lower right corner:
theDocWidthInPixels / 2, theDocHeightInPixels
theDocWidthInPixels / 2
indicates the middle of the document.