3

有什么方法可以使用 javascript 访问 pathItem 的填充不透明度?我可以访问整体不透明度,但我想降低填充的不透明度,同时保持笔触完全不透明。

我在文档中找不到任何内容,也找不到其他人问这个问题。

我可以像这样设置整体不透明度:

var selection = app.activeDocument.selection;
selection[0].opacity = 50;

我已经尝试了所有fillOpacity我能想到的“”变体,如下所示:

var selection = app.activeDocument.selection;
selection[0].fillOpacity = 50;
selection[0].FillOpacity = 50;
selection[0].fill.opacity = 50;

...但它不起作用。

我要解决这个问题,还是这不可能?

4

2 回答 2

4

您无法访问它,因为即使在 illustrator 中也无法正常访问它。这只是 Photoshop 属性。我也检查了文档以确保。你可以做的是这样,它会完成同样的事情:

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";
于 2012-04-26T16:06:08.670 回答
2

我为解决这个问题所做的是将专色应用于我使用 tint 属性的对象

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" ); 
于 2013-05-01T11:41:34.603 回答