有没有办法用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;
......但它不起作用。
我是否会犯这个错误,或者这是不可能的?
答案 0 :(得分:4)
您无法访问它,因为即使在插图画家中也无法正常访问它。这只是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";
答案 1 :(得分:2)
我为解决问题所做的是将spotcolor应用于我使用色调属性的对象
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" );