Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I need a way to randomly rotate gradient fills.

Community Beginner ,
Apr 15, 2009 Apr 15, 2009

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?

TOPICS
Scripting
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 16, 2009 Apr 16, 2009

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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2009 Apr 16, 2009

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2009 Apr 16, 2009
LATEST

Works for me. Good job, Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines