Copy link to clipboard
Copied
I can't find a way to flip an object or text horizontally or vertically using javascript. I looked at the transfomation matrix but that looks like it only scales, offsets and rotates an object or text.
Can I flip an object or text (horizontally or vertically) using javascript?
Thanks,
Mark
Copy link to clipboard
Copied
Try scaling it -100% in the direction you want it to flip
Copy link to clipboard
Copied
This is AppleScript but may provide an indication to the values you require for your matrix in JavaScript.
I did notice that even with about centre some times the bounds moved so I get the position then reposition you will need to test.
Transform about vertical axis:
tell application "Adobe Illustrator"
activate
set Doc_Ref to the current document
tell Doc_Ref
set Group_XY to position of group item 1 of layer 1
set RefVert_Matrix to ¬
{class:matrix, mvalue_a:-1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:1.0, mvalue_tx:0.0, mvalue_ty:0.0}
transform group item 1 of layer 1 using RefVert_Matrix about center
set position of group item 1 of layer 1 to Group_XY
end tell
end tell
Transform about horizontal axis:
tell application "Adobe Illustrator"
activate
set Doc_Ref to the current document
tell Doc_Ref
set Group_XY to position of group item 1 of layer 1
set RefHoz_Matrix to ¬
{class:matrix, mvalue_a:1.0, mvalue_b:0.0, mvalue_c:0.0, mvalue_d:-1.0, mvalue_tx:0.0, mvalue_ty:0.0}
transform group item 1 of layer 1 using RefHoz_Matrix about center
set position of group item 1 of layer 1 to Group_XY
end tell
end tell
hope this helps
Copy link to clipboard
Copied
Thanks guys. It wasn't obvious to me that "-" scale would flip the object.
In JS:
var mytextframe = mydoc.textFrames.add();
mytextframe.contents = "TEXT";
var myMatrix = getScaleMatrix(100,-100); //100,-100 flip vert, -100,100 flip horiz
mytextframe.transform(myMatrix);
Thanks again,
Mark
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more