我正在尝试使用.jsx脚本在Illustrator中设置当前选择的颜色。
我找不到有关更改(选定)对象的样式的文档。我已经阅读了大部分文档,但我似乎无法在任何地方找到这样一个“简单”的东西。这是我提出的代码:
thisThing = app.activeDocument.selection[0];
thisThing.filled = true;
thisThing.fillColor = '#ff0000';
当我运行它时,没有什么可悲的。
我找到了一个解决方案 - 它可行,但它非常混乱(由于是一个经过编辑的解决方案)。这为所选项目提供了随机灰色:
var myGrey= new CMYKColor()
myGrey.black=((Math.random()*80)+10);
if (app.documents.length && app.selection.length)
{
for (var a=0; a<app.selection.length; a++)
{
try {
app.selection[a].fillColor = myGrey;
} catch (e)
{
// ignoring all possible errors ...
}
}
}
如果你想做非灰度图:在1-100之间添加myGrey.Yellow =值;