2015-11-14 67 views
-1

是否有一個腳本可以遍歷每個swatchcolor,每次它複製「圖層1」並使用swatchcolor填充它?因此,如果樣本中有20種顏色,則會添加20個不同顏色的新圖層。illustrator fillcolor對象

如果是的話,每個新圖層都可以從swatch獲取名稱,並且可以將其導出爲swatchName.jpg?

回答

0

通過Illustrator JavaScript API你會發現Document對象有一個色板數組。所有剩下要做的就是:

  1. 遍歷每個樣本
  2. 得出當前色板顏色
  3. 出口的圖像

我建議使用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色板交換)的文件中所選擇的語言來導出圖像,共使用Illustrator避免。

相關問題