问题描述
是否可以使用javascript访问pathItem的填充不透明度?我可以访问整体不透明度,但是我想降低填充的不透明度,同时保持笔触完全不透明.
Is there any way to access a pathItem's fill opacity with javascript? I can access the overall opacity, but I want to lower the opacity of the fill while keeping the stroke fully opaque.
我在文档中找不到任何内容,也找不到其他人问这个问题.
I can't find anything in the documentation, nor can I find anyone else asking this question.
我可以像这样设置整体不透明度:
I can set the overall opacity like so:
var selection = app.activeDocument.selection;
selection[0].opacity = 50;
我尝试了所有可以想到的"fillOpacity
"变体,如下所示:
I've tried every variant of "fillOpacity
" that I can think of, like this:
var selection = app.activeDocument.selection;
selection[0].fillOpacity = 50;
selection[0].FillOpacity = 50;
selection[0].fill.opacity = 50;
...但是它不起作用.
...but it doesn't work.
我要解决这个错误,还是不可能?
Am I going about this wrong, or is this just not possible?
推荐答案
您无法访问它,因为即使在Illustrator中也无法正常访问它.这仅是Photoshop属性.我也检查了文档,只是为了确保.但是,您可以做的是,它将完成相同的事情:
You cannot access it, as you cannot access it normally even in illustrator. This is a Photoshop property only. I checked the documentation as well just to make sure. What you could do is this though and it would accomplish same thing:
doc = app.activeDocument;
i = 0
var selection = doc.selection[i];
var storedColor = doc.selection[i].fillColor;
//new object with only fill, we send it to back so it doesn't overlap stroke, if there is one
var newObject = app.selection[i].duplicate(doc, ElementPlacement.PLACEATEND);
//turn off fill for first object
doc.selection[i].filled = false;
i = i + 1;
newObject.stroked = false;
//apply stored color from earlier to new shape
newObject.fillColor = storedColor;
newObject.opacity = 50;
newObject.name = "50p fill";
这篇关于Illustrator ExtendScript设置FILL选择的不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!