Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scripting 如何使用photoshop脚本使用预定义模式填充选择_Scripting_Photoshop - Fatal编程技术网

Scripting 如何使用photoshop脚本使用预定义模式填充选择

Scripting 如何使用photoshop脚本使用预定义模式填充选择,scripting,photoshop,Scripting,Photoshop,如何使用photoshop脚本使用预定义模式填充选择 var docRef = app.documents.add() var layerRef =docRef.layerSets.add(); layerRef.kind = LayerKind.PATTERNFILL; docRef.selection.selectAll(); docRef.selection.fill(pattern?); 您需要一个模式ID—最简单的方法是使用scriptListener,通过快速测试填充查找并

如何使用photoshop脚本使用预定义模式填充选择

var docRef = app.documents.add()

var layerRef =docRef.layerSets.add();

layerRef.kind = LayerKind.PATTERNFILL;

docRef.selection.selectAll();

docRef.selection.fill(pattern?);

您需要一个模式ID—最简单的方法是使用scriptListener,通过快速测试填充查找并检查侦听器代码。下面是一个例子:

var myPattern = "d5706459-5277-11e7-aad4-ff82069d78d5";
fill_with_pattern(myPattern)

function fill_with_pattern(patternID)
{
    var idFl = charIDToTypeID( "Fl  " );
    var desc1283 = new ActionDescriptor();
    var idUsng = charIDToTypeID( "Usng" );
    var idFlCn = charIDToTypeID( "FlCn" );
    var idPtrn = charIDToTypeID( "Ptrn" );
    desc1283.putEnumerated( idUsng, idFlCn, idPtrn );
    var idPtrn = charIDToTypeID( "Ptrn" );
    var desc1284 = new ActionDescriptor();
    var idNm = charIDToTypeID( "Nm  " );
    desc1284.putString( idNm, """40x40""" ); // id name
    var idIdnt = charIDToTypeID( "Idnt" );
    desc1284.putString( idIdnt, patternID );
    var idPtrn = charIDToTypeID( "Ptrn" );
    desc1283.putObject( idPtrn, idPtrn, desc1284 );
    var idOpct = charIDToTypeID( "Opct" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc1283.putUnitDouble( idOpct, idPrc, 100.000000 ); //opacity
    var idMd = charIDToTypeID( "Md  " );
    var idBlnM = charIDToTypeID( "BlnM" );
    var idNrml = charIDToTypeID( "Nrml" );
    desc1283.putEnumerated( idMd, idBlnM, idNrml );
    executeAction( idFl, desc1283, DialogModes.NO );
}
我认为您可以通过名称而不是ID来调用模式,但我还没有成功地做到这一点。如果您尝试使用预先存在的模式(如气泡),您将得到如下代码:

desc1297.putString( idNm, """$$$/Presets/Patterns/Patterns_pat/Bubbles=Bubbles""" );
var idIdnt = charIDToTypeID( "Idnt" );
desc1297.putString( idIdnt, """b7334da0-122f-11d4-8bb5-e27e45023b5f""" );