Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

How to determine if a layer was flipped or rotated

$
0
0

I'm loooking for a way to determine if a layer has been flipped or rotated.  I found this code in a post that gets the rotation for a text layer, but I'm not able to adapt it to other layer types (e.g. art layers or smart objects) or to determine if the layer has been flipped.  Any help or pointers would be greatly appreciated!

 

 

function getActiveLayerRotation()

{

    var ref = new ActionReference();

    ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

   

    var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID('textKey'));

    if (desc.hasKey(stringIDToTypeID('transform')))

    {

        desc = desc.getObjectValue(stringIDToTypeID('transform'));

        var yy = desc.getDouble(stringIDToTypeID('yy'));

        var xy = desc.getDouble(stringIDToTypeID('xy'));

        var angle =  angleFromMatrix(yy, xy);      

        return angle;    

    }

}

 

function angleFromMatrix(yy, xy)

{

    var toDegs = 180/Math.PI;

    return Math.atan2(yy, xy) * toDegs - 90;

}


Viewing all articles
Browse latest Browse all 27456


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>