gpt4 book ai didi

javascript - 如何用颜色填充路径项

转载 作者:行者123 更新时间:2023-11-30 06:03:23 41 4
gpt4 key购买 nike

我正在尝试绘制闭合路径并用一些颜色填充它。代码在这里

startRulerUnits = app.preferences.rulerUnits

startTypeUnits = app.preferences.typeUnits

startDisplayDialogs = app.displayDialogs



//change settings

app.preferences.rulerUnits = Units.PIXELS

app.preferences.typeUnits = TypeUnits.PIXELS

app.displayDialogs = DialogModes.NO



var AD = activeDocument;



var bBox = new Array();

bBox[0] = 10;

bBox[1] = 10;



bBox[2] = 50;

bBox[3] = 10;



bBox[4] = 50;

bBox[5] = 50;



bBox[6] = 10;

bBox[7] = 50;



var line = new Array();

line[0] = new PathPointInfo;

line[0].kind = PointKind.CORNERPOINT;

line[0].anchor = [bBox[0],bBox[1]];

line[0].leftDirection = line[0].anchor;

line[0].rightDirection = line[0].anchor;



line[1] = new PathPointInfo;

line[1].kind = PointKind.CORNERPOINT;

line[1].anchor = [bBox[2],bBox[3]];

line[1].leftDirection = line[1].anchor;

line[1].rightDirection = line[1].anchor;



line[2] = new PathPointInfo;

line[2].kind = PointKind.CORNERPOINT;

line[2].anchor = [bBox[4],bBox[5]];

line[2].leftDirection = line[2].anchor;

line[2].rightDirection = line[2].anchor;



line[3] = new PathPointInfo;

line[3].kind = PointKind.CORNERPOINT;

line[3].anchor = [bBox[6],bBox[7]];

line[3].leftDirection = line[3].anchor;

line[3].rightDirection = line[3].anchor;



var lineSubPath= new Array();

lineSubPath[0] = new SubPathInfo();

lineSubPath[0].operation = ShapeOperation.SHAPEXOR;

lineSubPath[0].closed = true;

lineSubPath[0].entireSubPath = line;



var path = AD.pathItems.add("A", lineSubPath);



//var paperShape = AD.artLayers.add();



var colorRef = new SolidColor;

colorRef.rgb.red = 255

colorRef.rgb.green = 100;

colorRef.rgb.blue = 10;







path.fillPath(colorRef, ColorBlendMode.COLOR,100,true,0,true,true);



//shapeLayer.applyStyle("ransom_note");*/



app.preferences.rulerunits = startRulerUnits

app.preferences.typeunits = startTypeUnits

app.displayDialogs = startDisplayDialogs

路径绘制完成,但填充时出现错误

fillPath 不是函数。

有人可以帮忙吗?

附言对不起我的英语

最佳答案

pathApplication 的一个属性,当您尝试将 fillPath 应用于它时,Photoshop 无法理解,即使您已经声明了它作为变量名...您只会让 Photoshop 不知所措。

您只需将变量名称更改为 myPath 之类的名称,然后是 myPath.fillPath(colorRef, ColorBlendMode.COLOR,100,true,0,true,true); 会起作用。

我也会对 ColorBlendMode 做一点改变,如果你将它设置为 COLOR 你将无法真正看到你正在应用的颜色,并且脚本似乎根本不起作用。

试试 myPath.fillPath(colorRef, ColorBlendMode.NORMAL,100,true,0,true,true); 就大功告成了!

关于javascript - 如何用颜色填充路径项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6857643/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com