Adobe 65010248 Scripting Guide - Page 21

Color objects, Text objects, Text frames

Page 21 highlights

CHAPTER 2: The Illustrator Scripting Object Model Text objects 21 Color objects Your script can apply a color, pattern or gradient to a path item object, using the fill color or stroke color properties: ➤ Scripts can define new color swatches using the make command or add method of the swatches object. Your script also can create a new spot color, using the make command or add property of the spots object. ➤ You can define the attributes of an ink object using the ink info object, which is an ink object property. You access ink objects through the ink list property of the document object. The following objects allow you to create colors within defined color spaces: ➤ The RGB color object, using the range 0.0 to 255.0 for the each of the three individual color values. ➤ The CMYK color object, using the percentage values 0.0 through 100.0 for each of the four individual color values. ➤ The grayscale color or LAB color objects, using the same range and number of values that you use in the Illustrator application. Text objects When you type content in an Illustrator document, the type automatically becomes a text frame object and, at the same time, a story object. To observe this, open a new document in Illustrator and use the horizontal text tool to type some text, then use the vertical text tool to type more text. Finally, create a rectangle and type some text inside it. Now run the following JavaScript script: var myDoc = app.activeDocument alert("There are " + myDoc.textFrames.length + " text frames.") alert("There are " + myDoc.stories.length + " stories.") Text frames There are three types of text frames: ➤ point ➤ area ➤ path

  • 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

C
HAPTER
2: The Illustrator Scripting Object Model
Text objects
21
Color objects
Your script can apply a color, pattern or gradient to a
path
item
object, using the
fill
color
or
strokecolor
properties:
Scripts can define new color swatches using the
make
command or
add
method of the
swatches
object. Your script also can create a new spot color, using the
make
command or
add
property of the
spots
object.
You can define the attributes of an
ink
object using the
ink
info
object, which is an
ink
object
property. You access
ink
objects through the
ink list
property of the
document
object.
The following objects allow you to create colors within defined color spaces:
The
RGB
color
object, using the range 0.0 to 255.0 for the each of the three individual color values.
The
CMYK
color
object, using the percentage values 0.0 through 100.0 for each of the four individual
color values.
The
grayscale
color
or
LAB
color
objects, using the same range and number of values that you use
in the Illustrator application.
Text objects
When you type content in an Illustrator document, the type automatically becomes a
text
frame
object
and, at the same time, a
story
object.
To observe this, open a new document in Illustrator and use the horizontal text tool to type some text,
then use the vertical text tool to type more text. Finally, create a rectangle and type some text inside it.
Now run the following JavaScript script:
var myDoc = app.activeDocument
alert("There are " + myDoc.textFrames.length + " text frames.")
alert("There are " + myDoc.stories.length + " stories.")
Text frames
There are three types of text frames:
point
area
path