最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Illustrator javascript assign Color SwatchSpot Color to Path Item - Stack Overflow

programmeradmin0浏览0评论

I have a Javascript File which I use in Adobe Illustrator to create a Rectangle with the following Code:

var MyRect = artLayer.pathItems.rectangle( 12, 22, 180, 180 ); 

I have a Color Swatch / Spot Color with the Name "My_Color_01". How can I assign a color swatch and set its tint as a fill color to the rectangle I have created?

I have a Javascript File which I use in Adobe Illustrator to create a Rectangle with the following Code:

var MyRect = artLayer.pathItems.rectangle( 12, 22, 180, 180 ); 

I have a Color Swatch / Spot Color with the Name "My_Color_01". How can I assign a color swatch and set its tint as a fill color to the rectangle I have created?

Share Improve this question edited Feb 6 at 9:21 Penumbra asked Feb 6 at 9:11 PenumbraPenumbra 2073 silver badges8 bronze badges 2
  • 1 You can simply use app.activeDocument.swatches.getByName("My_Color_01"); – Trusha Jadeja Commented Feb 6 at 9:23
  • 1 This could be useful and your question might even be a duplicate of it – cybernetic.nomad Commented Feb 6 at 16:22
Add a comment  | 

1 Answer 1

Reset to default 1

Here you go:

var doc = app.activeDocument;
var artLayer = doc.layers[0];
var color = doc.swatches.getByName('My_Color_01').color;
color.tint = 50; // <-- 50% tint, for example
var MyRect = artLayer.pathItems.rectangle( 12, 22, 180, 180 );
MyRect.fillColor = color;
发布评论

评论列表(0)

  1. 暂无评论