Working With Transformation Matrices - Adobe 0046100128056 - InDesign - Mac Manual

Javascript
Table of Contents

Advertisement

C
5: Working with Page Items
HAPTER
The following scripting example demonstrates the basic process of transforming a page item. (For the
complete script, see TransformExamples.)
//Rotate a rectangle "myRectangle" around its center point.
var myRotateMatrix =
app.transformationMatrices.add({counterclockwiseRotationAngle:27});
myRectangle.transform(CoordinateSpaces.pasteboardCoordinates,
AnchorPoint.centerAnchor, myRotateMatrix);
//Scale a rectangle "myRectangle" around its center point.
var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:.5,
verticalScaleFactor:.5});
myRectangle.transform(CoordinateSpaces.pasteboardCoordinates,
AnchorPoint.centerAnchor, myScaleMatrix);
//Shear a rectangle "myRectangle" around its center point.
var myShearMatrix =app.transformationMatrices.add({clockwiseShearAngle:30});
myRectangle.transform(CoordinateSpaces.pasteboardCoordinates,
AnchorPoint.centerAnchor, myShearMatrix);
//Rotate a rectangle "myRectangle" around a specified ruler point ([72, 72]).
var myRotateMatrix =
app.transformationMatrices.add({counterclockwiseRotationAngle:27});
myRectangle.transform(CoordinateSpaces.pasteboardCoordinates, [[72, 72],
AnchorPoint.topLeftAnchor], myRotateMatrix, undefined, true);
//Scale a rectangle "myRectangle" around a specified ruler point ([72, 72]).
var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:.5,
verticalScaleFactor:.5});
myRectangle.transform(CoordinateSpaces.pasteboardCoordinates, [[72, 72],
AnchorPoint.topLeftAnchor], myScaleMatrix, undefined, true);
For a script that "wraps" transformation routines in a series of easy-to-use functions, refer to the Transform
script.

Working with transformation matrices

A transformation matrix cannot be changed once it has been created, but a variety of methods can
interact with the transformation matrix to create a new transformation matrix based on the existing
transformation matrix. In the following examples, we show how to apply transformations to a
transformation matrix and replace the original matrix. (For the complete script, see TransformMatrix.)
//Scale a transformation matrix by 50% in both horizontal and vertical dimensions.
var myTransformationMatrix = myTransformationMatrix.scaleMatrix(.5, .5);
//Rotate a transformation matrix by 45 degrees.
myTransformationMatrix = myTransformationMatrix.rotateMatrix(45);
//Shear a transformation matrix by 15 degrees.
myTransformationMatrix = myTransformationMatrix.shearMatrix(15);
When you use the
rather than an angle in degrees, as shown in the RotateMatrix script.
//The following statements are equivalent
//(0.25881904510252 is the sine of 15 degrees; 0.96592582628907, the cosine).
myTransformationMatrix = myTransformationMatrix.rotateMatrix(15);
myTransformationMatrix = myTransformationMatrix.rotateMatrix(undefined,
0.96592582628907);
myTransformationMatrix = myTransformationMatrix.rotateMatrix(undefined, undefined,
0.25881904510252);
When you use the
shown in the ShearMatrix script.
method, you can use a sine or cosine value to transform the matrix,
rotateMatrix
, you can provide a slope, rather than an angle in degrees, as
shearMatrixmethod
Transforming Page Items 63

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 0046100128056 - InDesign - Mac and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Indesign cs5

Table of Contents