我正在尝试使用Photoshop动作来生成由图层的随机采样组成的随机图像。我有3组图层,默认情况下所有图层都不可见。
示例组/层:
[FRUITS]
* [Apples]
* [Oranges]
* [Pears]
* [Bananas]
* [Kiwis]
[VEGGIES]
* [Asparagus]
* [Cilantro]
* [Eggplant]
[MEATS]
* [Beef]
* [Pork]
默认情况下,所有图层都是隐藏的,但是当我执行一个动作时,我可能会得到以下结果(可见图层):
Image1: [Apples] [Eggplant] [Pork]
Image2: [Pears] [Asparagus] [Pork]
Image3: [Kiwis] [Cilantro] [Beef]
答案 0 :(得分:0)
这是我的脚本,但是在运行它之前不要忘记执行以下步骤:
现在您已经准备好摇滚了。
功能
从组中创建所需的无限图案。
将所有样式另存为索引为PNG
的单独文件夹中的单独PNG。
观看GIF(如下)以了解更多信息:
function Visible() {
var Grps = app.activeDocument.layerSets; // loops through all groups
for(var i = 0; i < Grps.length; i++){
var tmp = app.activeDocument.layerSets[i].layers.length;
app.activeDocument.layerSets[i].visible=true;
var groupChildArr = app.activeDocument.layerSets[i].layers;
var randLays = Math.floor(Math.random() * tmp);
groupChildArr[randLays].visible = true;
Save();
}
Revert();
}
function Save() {
var outFolder = app.activeDocument; // psd name
var outPath = outFolder.path;
var fName = "PNG"; // define folder name
var f = new Folder(outPath + "/" + fName);
if ( ! f.exists ) {
f.create()
}
var saveFile = new File(outPath + "/" + fName +"/" + "Pattern_" + num + ".png");
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.interlaced = false;
app.activeDocument.saveAs(saveFile, pngSaveOptions, true, Extension.LOWERCASE);
}
function Revert(){
var idslct = charIDToTypeID( "slct" );
var desc300 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref163 = new ActionReference();
var idSnpS = charIDToTypeID( "SnpS" );
ref163.putName( idSnpS, "test.psd" );
desc300.putReference( idnull, ref163 );
executeAction( idslct, desc300, DialogModes.NO );
}
var count = prompt("How many patterns you want","");
for (var x=0 ; x<count;x++){
var num = x+1;
Visible();
}