如何在jsx photoshop脚本中提取图层旋转(变换)?

时间:2013-11-13 14:09:00

标签: photoshop photoshop-script jsx

使用Free Transform工具将图层旋转90度后......

如何使用jsx脚本找到此值?

1 个答案:

答案 0 :(得分:11)

哦,我的好,我花了4个小时才找到它:(

function angleFromMatrix(yy, xy)
{
    var toDegs = 180/Math.PI;
    return Math.atan2(yy, xy) * toDegs - 90;
}

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'));
        return angleFromMatrix(yy, xy);
    }
    return 0;
}