使用脚本从文本的起点旋转 Photoshop 文本
Rotate Photoshop Text With Script From Starting Point Of Text
我正在使用下面的脚本旋转文本层
它从文本的中间点旋转
有没有办法在脚本中从文本的左侧(起点)旋转?
var idRtte = charIDToTypeID( "Rtte" );
var desc199 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref15 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref15.putEnumerated( idLyr, idOrdn, idTrgt );
desc199.putReference( idnull, ref15 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc199.putUnitDouble( idAngl, idAng, rotation);
executeAction( idRtte, desc199, DialogModes.NO );
Photoshop 使用附加描述符来定义轴心点:层角有多个硬编码字符串,使用 2 个绝对坐标的自定义轴心点有一个更扩展的描述符。
预定义角:
// 'Qcs0' top left
// 'Qcs7' middle left
// 'Qcs3' bottom left
// 'Qcs4' top center
// 'Qcsa' middle center
// 'Qcs6' bottom center
// 'Qcs1' top right
// 'Qcs5' middle right
// 'Qcs2' bottom right
function rotatePivot(pivot, angle)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
desc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID(pivot));
desc.putUnitDouble(charIDToTypeID('Angl'), charIDToTypeID('#Ang'), angle);
executeAction(charIDToTypeID('Trnf'), desc, DialogModes.NO);
} // end of rotatePivot()
rotatePivot('Qcs3', 45);
自定义枢轴。 pivotCoords
是一个绝对坐标数组。
// 'Qcsi' custom pivot
function rotateCustomPivot(pivotCoords, angle)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
desc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsi'));
var descPivot = new ActionDescriptor();
descPivot.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), pivotCoords[0]);
descPivot.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), pivotCoords[1]);
desc.putObject(charIDToTypeID('Pstn'), charIDToTypeID('Pnt '), descPivot);
desc.putUnitDouble(charIDToTypeID('Angl'), charIDToTypeID('#Ang'), angle);
executeAction(charIDToTypeID('Trnf'), desc, DialogModes.NO);
} // end of rotateCustomPivot()
// b[0] and b[3] are bottom-left coord of a layer,
// so this will rotate using a custom point
// that's 10 pixels away from that coord by x and y
var b = activeDocument.activeLayer.bounds;
var x = b[0] - 10;
var y = b[3] + 10;
rotateCustomPivot([x, y], 45);
我正在使用下面的脚本旋转文本层
它从文本的中间点旋转
有没有办法在脚本中从文本的左侧(起点)旋转?
var idRtte = charIDToTypeID( "Rtte" );
var desc199 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref15 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref15.putEnumerated( idLyr, idOrdn, idTrgt );
desc199.putReference( idnull, ref15 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc199.putUnitDouble( idAngl, idAng, rotation);
executeAction( idRtte, desc199, DialogModes.NO );
Photoshop 使用附加描述符来定义轴心点:层角有多个硬编码字符串,使用 2 个绝对坐标的自定义轴心点有一个更扩展的描述符。
预定义角:
// 'Qcs0' top left
// 'Qcs7' middle left
// 'Qcs3' bottom left
// 'Qcs4' top center
// 'Qcsa' middle center
// 'Qcs6' bottom center
// 'Qcs1' top right
// 'Qcs5' middle right
// 'Qcs2' bottom right
function rotatePivot(pivot, angle)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
desc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID(pivot));
desc.putUnitDouble(charIDToTypeID('Angl'), charIDToTypeID('#Ang'), angle);
executeAction(charIDToTypeID('Trnf'), desc, DialogModes.NO);
} // end of rotatePivot()
rotatePivot('Qcs3', 45);
自定义枢轴。 pivotCoords
是一个绝对坐标数组。
// 'Qcsi' custom pivot
function rotateCustomPivot(pivotCoords, angle)
{
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc.putReference(charIDToTypeID('null'), ref);
desc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsi'));
var descPivot = new ActionDescriptor();
descPivot.putUnitDouble(charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), pivotCoords[0]);
descPivot.putUnitDouble(charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), pivotCoords[1]);
desc.putObject(charIDToTypeID('Pstn'), charIDToTypeID('Pnt '), descPivot);
desc.putUnitDouble(charIDToTypeID('Angl'), charIDToTypeID('#Ang'), angle);
executeAction(charIDToTypeID('Trnf'), desc, DialogModes.NO);
} // end of rotateCustomPivot()
// b[0] and b[3] are bottom-left coord of a layer,
// so this will rotate using a custom point
// that's 10 pixels away from that coord by x and y
var b = activeDocument.activeLayer.bounds;
var x = b[0] - 10;
var y = b[3] + 10;
rotateCustomPivot([x, y], 45);