是否有一个脚本可以遍历每个swatchcolor,每次它复制“第1层”并用swatchcolor填充它?因此,如果样本中有20种颜色,则会添加20个具有不同颜色的新图层。
如果是,是否每个新图层都可以从样本中获取名称,并且还可以将其导出为swatchName.jpg?
答案 0 :(得分:1)
通过Illustrator JavaScript API,您会注意到Document对象有一个样本数组。剩下要做的就是:
我建议使用png-24而不是jpg来避免压缩伪影。
这是一个注释脚本,首先提示输出文件夹:
#target illustrator
//get a reference to the the current document
var doc = app.activeDocument;
//...and it's swatches
var swatches = doc.swatches;
//select a folder to save images into
var savePath = Folder.selectDialog( 'Please select a folder to export swatch images into', '~' );
//exported image dimensions
var width = 100;
var height = 100;
//PNG export options
var pngExportOpts = new ExportOptionsPNG24();
pngExportOpts.antiAliasing = false;//keep it pixel perfect
pngExportOpts.artBoardClipping = false;//use the path's dimensions (setup above), ignore full document size
pngExportOpts.saveAsHTML = false;
pngExportOpts.transparency = true;//some swatches might have transparency
//remove strokes
doc.defaultStroked = false;
//go through the swatches
for(var i = 0; i < swatches.length; i++){
//add a rectangle
var rect = doc.pathItems.rectangle(0, 0, width, height);
//set the fill colour based on the current swatch colour
rect.fillColor = swatches[i].color;
//export png
doc.exportFile( new File( savePath+ '/' + swatches[i].name + '.png'), ExportType.PNG24, pngExportOpts );
//remove any previous paths (in case of transparent swatches)
doc.pathItems.removeAll();
}
值得注意的是,您可以使用所选语言parse .ase(Adobe Swatch Exchange)文件导出图像,避免完全使用Illustrator。