Copy link to clipboard
Copied
Hello,
I am looking to add some more control to a script where I use a CSV file to create unique designs per page. For eample a csv file would have the shirt size, T Shirt color, and if any font is put on the shirt. The script works great but now I was thinking to add a gradient option. Ideally I would like to add the gradient to have 2 colors but not sure how to do thi. Below you can see I change the fill and color.
myPage=app.activeDocument.pages.item(i).select();
myPageItems=app.documents.item(0).pages.item(i);
myPolygon=myPageItems.polygons.item("frmLEFT-090-VAMP");
myPolygon.visible=true;
myPolygon.fillColor="TEAM_YELLOW";
myPolygon.strokeColor="BLACK_NB";
myPolygon=myPageItems.polygons.item("frmRIGHT-090-VAMP");
myPolygon.visible=true;
myPolygon.fillColor="TEAM_ROYAL";
myPolygon.strokeColor="BLACK_NB";
I can add the gradient to the Polygon in InDesign but then I would need a way to turn on off if we have design wanting no gradient... Any help would be appreciated.
Thanks.
Bill
Copy link to clipboard
Copied
The myPolygon.fillColor could be the name of a gradient swatch, which you could also create via scripting—gradient, and gradient.gradientStops.stopColor
And then the positioning would be properties of the polygon object myPolygon.gradientFillAngle, myPolygon.gradientFillLength, myPolygon.gradientFillStart,
https://www.indesignjs.de/extendscriptAPI/indesign10/#Polygon.html
Also ask at the inDesign Scripting forum
Copy link to clipboard
Copied
Discussion moved to InDesign Scripting​
Copy link to clipboard
Copied
If you have added the desired gradient to the swatch then applying it to the polygon object is just the same as using another swatch. Something like the following would work, where GS is the name of the gradient swatch
myPolygon.fillColor = app.documents[0].swatches.itemByName("GS")
If you want to even add the gradient to Swatches using scripting you can go through the following discussion
-Manan
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more