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 Answer
Reset to default 1Here 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;
app.activeDocument.swatches.getByName("My_Color_01");
– Trusha Jadeja Commented Feb 6 at 9:23