Tuesday, November 30, 2010

Flip an object

This morning, Steve from the UK wrote me and asked me how to run a "reflect x" command on an object using JavaScript.
I assumed this could be solved with a simple command, such as in ActionScript, where you can write "scaleX= -1", but after peeking through the docs, I couldn't find any "scale" properties on the objects.

I found the answer in the matrix object (found on page 99 of the CS5  Javascript scripting reference)
For  convenience, here's an example code to flip every object in your document along the 'y' axis: (reflect x)

if ( app.documents.length > 0 ) {

    // here's the "flip horizontal" magic:
    var totalMatrix = app.getScaleMatrix(-100,100);

    // apply the transformation to all art in the document
    var doc = app.activeDocument;
    for ( i = 0; i < doc.pageItems.length; i++ ) {
        doc.pageItems[i].transform( totalMatrix );
    }
}

cheers,
-J

Sunday, November 14, 2010

More from Daniel Van Willigen

While I've been busy playing with Flash and Actionscript, Daniel has been busy writing new and improving existing scripts. Now everything is CS3 compatible. See the link at the bottom of this post for a zip file of everything mentioned here.

Daniel's sent me the boxit script and circleit scripts from last time, and now has some new ones as well. There is starit, smileit, and blowfishit which display the respective critters in purdy geometric arrangements.

He has a cool customizable wave generating script called Totally Twisted.

Also included in the zip is his Trace vector to script which he used to create some of the above scripts. Check out his "blowfishit" script as a cute example.
All of the above lovingly zipped into a convenient bundle for your perusal here.

cheers,
-J