Adobe 0046100128056 - InDesign - Mac Manual page 58

Javascript
Table of Contents

Advertisement

C
5: Working with Page Items
HAPTER
Changing the zero point location by either dragging the zero point or by changing the ruler origin
changes the coordinates on the rulers.
Page items are made up of one or more paths, which, in turn, are made up of two or more path points.
Paths can be open or closed.
Path points contain an anchor point (the location of the point itself ) and two control handles (left
direction, which controls the curve of the line segment preceding the point on the path; and right
direction, which controls the curve of the segment following the point). Each of these properties
contains an array in the form (
location). This array holds the location, in current ruler coordinates, of the point or control handle.
All of the above means that if your scripts need to construct page items, you also need to control the
location of the zero point, and you may want to set the measurement units in use.
Working with paths and path points
For most simple page items, you do not need to worry about the paths and path points that define the
shape of the object. Rectangles, ellipses, and text frames can be created by specifying their geometric
bounds, as we did in the earlier example in this chapter.
In some cases, however, you may want to construct or change the shape of a path by specifying path point
locations, you can either set the anchor point, left direction, and right direction of each path point on the
path individually (as shown in the DrawRegularPolygon_Slow script), or you can use the entirePath
property of the path to set all of the path point locations at once (as shown in the
DrawRegularPolygon_Fast script). The latter approach is much faster.
The items in the array you use for the entirePath property can contain anchor points only, or a anchor
points and control handles. Here is an example array containing only anchor point locations:
[[x1, y1], [x2, y2], ...]
Where
x
Here is an example containing fully-specified path points (i.e., arrays containing the left direction, anchor,
and right direction, in that order):
[[xL1, YL1], [x1, y1], [xR1, yR1]], [[xL2, YL2], [x2, y2], [xR2, yR2]], ...]
Where
xL
direction.
You can also mix the two approaches, as shown in the following example:
[[[xL1, YL1], [x1, y1], [xR1, yR1]], [x2, y2], ...]
Note that the original path does not have to have the same number of points as you specify in the
array—InDesign will add or subtract points from the path as it applies the array to the entirePath property.
The AddPathPoint script shows how to add path points to a path without using the entirePath property.
//Given a graphic line "myGraphicLine"...
var myPathPoint = myGraphicLine.paths.item(0).pathPoints.add();
//Move the path point to a specific location.
myPathPoint.anchor = [144, 144];
The DeletePathPoint script shows how to delete a path point from a path.
and
specify the location of the anchor.
y
and
specify the left direction,
yL
,
) (where
is the horizontal location of the point, and
x
y
x
and
specify the anchor point, and
x
y
Creating Page Items 58
is the vertical
y
and
specify the right
xR
yR

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents