javascript - Illustrator ExtendScript set FILL opacity of selection - Stack Overflow

Is there any way to access a pathItem's fill opacity with javascript? I can access the overall opa

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;

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?

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;

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?

Share Improve this question asked Mar 27, 2012 at 23:37 cr0ybotcr0ybot 4,0902 gold badges21 silver badges24 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

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 acplish 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";

What I did to solve the problem is to apply a spotcolor to the objects where I uses the tint property

var docRef = app.activeDocument;
var selectedObjects = docRef.selection;
var theTint;
var fillwithSwatch = function (pathItems, sname ){

for (var i=0;i< pathItems.length; i++){
pathItems[i].fill = true;
theTint = pathItems[i].fillColor.gray;
pathItems[i].fillColor = docRef.swatches.getByName ( sname ).color ;
pathItems[i].fillColor.tint = theTint; 
}
}
theTint = fillTint(selectedObjects);
// the spotcolor should be in the swatchpallet already
fillwithSwatch (selectedObjects, "myBlue" ); 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745368115a4624675.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信