Copy link to clipboard
Copied
I have a bunch of shapes that I would like to fill with a simple black to white gradient that is rotated at different angles. I tried to create a pattern and utilize the transform each option but it does not let me rotate only the pattern, it wants to rotate the entire vector. Is this something that could be done with a script?
Copy link to clipboard
Copied
It seems this might work:
#target illustrator
var myDocument = app.activeDocument;
var theItem = myDocument.pathItems[0];
theItem.rotate(Math.random()*360, false, false, true, false);
Copy link to clipboard
Copied
I had left out a clause to adress more than the topmost object, so this should rotate the gradients of all the objects in a selection or a document:
#target illustrator
var myDocument = app.activeDocument;
if (myDocument.selection.length == 0) {
for (var m = 0; m < myDocument.pathItems.length; m++) {
var theItem = myDocument.pathItems
theItem.rotate(Math.random()*360, false, false, true, false)
}
}
else {
var theSelection = myDocument.selection;
for (var m = 0; m < theSelection.length; m++) {
var theItem = theSelection
theItem.rotate(Math.random()*360, false, false, true, false)
}
};
Actually I’m not that good with Scripting, especially for Illustrator, so hopefully someone more experienced will correct possible mistakes or shortcomings.
Copy link to clipboard
Copied
Works for me. Good job, Chris
Find more inspiration, events, and resources on the new Adobe Community
Explore Now