Matrix
Matrix
Section titled “Matrix”matrix
Description
Section titled “Description”A transformation matrix specification, used to transform the geometry of objects. Use it to specify and retrieve matrix information from an Illustrator document or from page items in a document.
Matrices are used in conjunction with the transform
method and as a property of a number of objects. A matrix specifies how to transform the geometry of an object. You can generate an original matrix using the Application object methods Application.getTranslationMatrix(), Application.getScaleMatrix(), or Application.getRotationMatrix().
A Matrix
is a record containing the matrix values, not a reference to a matrix object. The matrix commands operate on the values of a matrix record. If a command modifies a matrix, a modified matrix record is returned as the result of the command. The original matrix record passed to the command is not modified.
Properties
Section titled “Properties”Matrix.mValueA
Section titled “Matrix.mValueA”matrix.mValueA
Description
Section titled “Description”Matrix property a
.
Number (double).
Matrix.mValueB
Section titled “Matrix.mValueB”matrix.mValueB
Description
Section titled “Description”Matrix property b
.
Number (double).
Matrix.mValueC
Section titled “Matrix.mValueC”matrix.mValueC
Description
Section titled “Description”Matrix property c
.
Number (double).
Matrix.mValueD
Section titled “Matrix.mValueD”matrix.mValueD
Description
Section titled “Description”Matrix property d
.
Number (double).
Matrix.mValueTX
Section titled “Matrix.mValueTX”matrix.mValueTX
Description
Section titled “Description”Matrix property tx
.
Number (double).
Matrix.mValueTY
Section titled “Matrix.mValueTY”matrix.mValueTY
Description
Section titled “Description”Matrix property ty
.
Number (double).
Matrix.typename
Section titled “Matrix.typename”matrix.typename
Description
Section titled “Description”The class name of the referenced object.
String; read-only.
Example
Section titled “Example”Combining matrices to apply multiple transformations
Section titled “Combining matrices to apply multiple transformations”To apply multiple transformations to objects, it is more efficient to use the matrix suite than to apply the transformations one at a time. The following script demonstrates how to combine multiple matrices.
// Tranforms all art in a document using translation and rotation matrices,// moves art half an inch to the right and 1.5 inches up on the pageif (app.documents.length > 0) { var moveMatrix = app.getTranslationMatrix(0.5, 1.5);
// Add a rotation to the translation, 10 degrees counter clockwise var totalMatrix = concatenateRotationMatrix(moveMatrix, 10);
// apply the transformation to all art in the document var doc = app.activeDocument; for (var i = 0; i < doc.pageItems.length; i++) { doc.pageItems[i].transform(totalMatrix); }}