Skip to main content
Participant
September 9, 2016
Question

Random coloring words

  • September 9, 2016
  • 1 reply
  • 927 views

Hi,

I have a group of words changed to curves. I would like to whole words got random colors, not as individual letters. It is possible?

I tried free scprit Random-Swatch-Fill but it doesn't work with groups but idea of action is very similar.

This topic has been closed for replies.

1 reply

Inspiring
September 9, 2016

Hey! Assuming that you have a loop that looks like this

loop through shapes {

     pick random color;

     shape.fillColor = random color;

}

all you need to do is move the pick random color to before the loop

pick random color;

loop through shapes {

     shape.fillColor = random color;

}

If you post the code I can be a bit more specific, but that's the general idea.

Participant
September 9, 2016

Code of Random Swatch Fill

mySelection = app.activeDocument.selection;

myDoc = app.activeDocument;

if (mySelection instanceof Array)

{

  selSwatches = myDoc.swatches.getSelected();

  if(selSwatches.length != 0)

  for (i=0; i<mySelection.length; i++)

  {

  if(mySelection.typename == "PathItem" || mySelection.typename == "CompoundPathItem")

  {

  selItem = mySelection;

  selItem.filled = true;

  swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

  if(selItem.typename == "PathItem")

  selItem.fillColor = selSwatches[swatchIndex].color;

  else

  selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;

  }

  }

}

Inspiring
September 9, 2016

I added some comments

function RandomColor() {

myDoc = app.activeDocument;  // current document file

mySelection = app.activeDocument.selection;   // get anything that's selected in the current document

if (mySelection instanceof Array)

{

    selSwatches = myDoc.swatches.getSelected();  // get any selected swatches

   

    if(selSwatches.length != 0)

    {

        ///////////////// This is the big change ///////////////////

        // select an index at random from our list of selected swatches

        swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

        /////////////////////////////////////////////////////////////////////////////

       

        // loop through everything that's selected

        for (i=0; i<mySelection.length; i++)

        {

            // if the current item we're checing is either a Path Item or a Compound Path Item

            if(mySelection.typename == "PathItem" || mySelection.typename == "CompoundPathItem")

            {

                // get the current item from our list of selected items

                selItem = mySelection;

                selItem.filled = true;

               

                // set it's fill color to our random swatch color

                if(selItem.typename == "PathItem")

                    selItem.fillColor = selSwatches[swatchIndex].color;

                else

                    selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;

            }

        }

    }

}

}

RandomColor();

Good luck! :-)