如何用颜色填充路径项

发布于 2024-11-27 00:49:46 字数 2070 浏览 1 评论 0原文

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

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 is not a function.

时出现错误。有人可以帮忙吗?

PS对不起我的英语

I'm trying to draw closed path and fill it with some collor. Here the code

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

path is drawn, but error apears while filling

fillPath is not a function.

Can anybody help?

P.S. Sorry for my English

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不爱素颜 2024-12-04 00:49:46

pathApplication 的一个属性,当您尝试将 fillPath 应用于它时,Photoshop 无法理解,即使您已将其声明为变量name...你只会让 Photoshop 感到困惑,不知道该怎么做。

您只需将其变量名称更改为 myPath 之类的内容,然后 myPath.fillPath(colorRef, ColorBlendMode.COLOR,100,true,0,true,true); 即可工作。

我还会在 ColorBlendMode 中进行一些更改,如果将其设置为 COLOR,您将无法实际看到您正在应用的颜色,并且看起来该脚本根本不起作用。

尝试 myPath.fillPath(colorRef, ColorBlendMode.NORMAL,100,true,0,true,true); 就完成了!

path is a property of Application, Photoshop does not understand when you try to apply fillPath to it, even if you had declared it as a variable name... you just gets Photoshop confused on what to do.

You should simply change that's variable name to something like myPath and then myPath.fillPath(colorRef, ColorBlendMode.COLOR,100,true,0,true,true); will work.

I would also make a little change in the ColorBlendMode, if you set it to COLOR you won't be able to actually see the color you are applying, and it will seem that the script is not working at all.

Try myPath.fillPath(colorRef, ColorBlendMode.NORMAL,100,true,0,true,true); and you're done!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文