Skip to main content
Participating Frequently
June 25, 2009
Question

Transformation Matrix JS

  • June 25, 2009
  • 1 reply
  • 2883 views

Hi,

I am using Javascript to try and resize some clipping paths to fit to the artboard. 

The only thing I am having trouble with is being able to set the new cooridinates of the clipping path box.  I think I have to use the transform method, but I am not sure.  Is this possible? If so, what is the code that I should be using?

Thanks,

Justin M.

This topic has been closed for replies.

1 reply

Known Participant
August 17, 2009

Hi,

This is my first post and the first time I use JavaScript and Illustrator.

It seems there's not much activity here though

Anyway...

I didn't get what class you want to transform

the good news is, as far as I see in the documentation, most objects displayed have a transform method which accepts a matrix.

I haven't figured out how to retrieve a transformation matrix for an object yet.

Application comes with some methods for creating matrices.

You might need a scale matrix.

Just as a test, draw a rectanglem, make sure it's still selected, type this code and try to run it

var topObject = app.activeDocument.selection[0];
var scaleMatrix = app.getScaleMatrix (500, 500);
topObject.transform (scaleMatrix);

this should scale the object to be 500x500.

to move object you can use app.getTranslationMatrix( yourXValue, yourYValue );

and you can combine matrices together to do more transformations in one go

e.g.

var moveMatrix = app.getTranslationMatrix( 0.5, 1.5 );
var rotatelMatrix = concatenateRotationMatrix( moveMatrix, 10 );

the code comes from the reference, just do a search for matrix inside the document.

http://www.adobe.com/devnet/illustrator/pdfs/IllustratorCS3_JavaScript_Reference.pdf

good luck!