Dir*_*rly 5 javascript photoshop api
我在 JS 中编写了一个 Photoshop 脚本,它将每个图层文件夹都像精灵表一样将其隔开。我已经弄清楚了那部分,但我试图在运行脚本时消除任何形式的人为错误。现在,您需要使用每个图层文件夹的正确命名来准备文件,并且还必须将图层蒙版应用于选择。
我想消除用户应用图层蒙版的需要。我可以选择图层,然后选择要遮罩的部分,但我不知道如何应用或创建遮罩。
我希望它被应用的地方:
function maskIt(){
if(currentFrameCount < (frameNumber-1)){
currentFrameCount = currentFrameCount+1;
currentFrame = ("frame"+currentFrameCount);
activeDocument.layers[currentFrame].visable;
activeDocument.selection.selectAll();
//createMask();
maskComplete = false;
} else if (currentFrameCount == (frameNumber-1)){
currentFrameCount = currentFrameCount+1;
currentFrame = ("frame"+currentFrameCount);
activeDocument.layers[currentFrame].visable;
activeDocument.selection.selectAll();
//createMask();
currentFrameCount = 0;
maskComplete = true;
}
}
Run Code Online (Sandbox Code Playgroud)
从脚本侦听器整理的这两个函数应该可以帮助您:
// FUNCTION MAKE MASK ()
function makeMask()
{
// =======================================================
var id4556 = charIDToTypeID( "setd" );
var desc983 = new ActionDescriptor();
var id4557 = charIDToTypeID( "null" );
var ref657 = new ActionReference();
var id4558 = charIDToTypeID( "Chnl" );
var id4559 = charIDToTypeID( "fsel" );
ref657.putProperty( id4558, id4559 );
desc983.putReference( id4557, ref657 );
var id4560 = charIDToTypeID( "T " );
var ref658 = new ActionReference();
var id4561 = charIDToTypeID( "Chnl" );
var id4562 = charIDToTypeID( "Chnl" );
var id4563 = charIDToTypeID( "Trsp" );
ref658.putEnumerated( id4561, id4562, id4563 );
desc983.putReference( id4560, ref658 );
executeAction( id4556, desc983, DialogModes.NO );
// =======================================================
var id4564 = charIDToTypeID( "Mk " );
var desc984 = new ActionDescriptor();
var id4565 = charIDToTypeID( "Nw " );
var id4566 = charIDToTypeID( "Chnl" );
desc984.putClass( id4565, id4566 );
var id4567 = charIDToTypeID( "At " );
var ref659 = new ActionReference();
var id4568 = charIDToTypeID( "Chnl" );
var id4569 = charIDToTypeID( "Chnl" );
var id4570 = charIDToTypeID( "Msk " );
ref659.putEnumerated( id4568, id4569, id4570 );
desc984.putReference( id4567, ref659 );
var id4571 = charIDToTypeID( "Usng" );
var id4572 = charIDToTypeID( "UsrM" );
var id4573 = charIDToTypeID( "RvlS" );
desc984.putEnumerated( id4571, id4572, id4573 );
executeAction( id4564, desc984, DialogModes.NO );
}
// FUNCTION APPLY LAYER MASK()
function applyLayerMask()
{
// =======================================================
var id1949 = charIDToTypeID( "Dlt " );
var desc398 = new ActionDescriptor();
var id1950 = charIDToTypeID( "null" );
var ref291 = new ActionReference();
var id1951 = charIDToTypeID( "Chnl" );
var id1952 = charIDToTypeID( "Chnl" );
var id1953 = charIDToTypeID( "Msk " );
ref291.putEnumerated( id1951, id1952, id1953 );
desc398.putReference( id1950, ref291 );
var id1954 = charIDToTypeID( "Aply" );
desc398.putBoolean( id1954, true );
executeAction( id1949, desc398, DialogModes.NO );
}
Run Code Online (Sandbox Code Playgroud)
如果您试图排除人为错误,您可能需要第三个函数来检测图层是否具有蒙版(选择该图层,尝试复制并粘贴图层蒙版;如果没有粘贴 - 否)图层蒙版)
| 归档时间: |
|
| 查看次数: |
5566 次 |
| 最近记录: |