EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Page 58

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 5: Working with Page Items Creating Page Items 58
X
Changing the zero point location by either dragging the zero point or by changing the ruler origin
changes the coordinates on the rulers.
X 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.
X 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 (
x, y) (where x is the horizontal location of the point, and y is the vertical
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 and y specify the location of the anchor.
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 and yL specify the left direction, x and y specify the anchor point, and xR and yR specify the right
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.

Table of Contents

Related product manuals