1

I'm trying to create hexagonal pattern of slightly offset colors. Similar to Code Review's background, but with hexagons.

I've attempted to draw a hexagon and slightly change the colors but doing this ~800 times would be highly impractical.

So essentially, how would I create a group objects with slightly different colors for each

Here's a rough example of what I've tried so far.

Rough Example

3
  • Please formulate your question more clearly. What is it you want to achieve and have problems with? Thanks!
    – Vincent
    Jan 5, 2016 at 9:24
  • A simple google query lead me to this: forums.adobe.com/thread/450301?start=0&tstart=0, which really looks like what you are after.
    – Jongware
    Jan 5, 2016 at 10:15
  • @Jongware Im not sure that qualifies if he wants every item to have different color and not just swatches but yes randomizing scripts exist.
    – joojaa
    Jan 5, 2016 at 10:17

3 Answers 3

6

A quickly written Javascript to randomize the RGB fill color of a selected set of objects:

var adjustRanges = {
  red:{min:-40, max:40},
  green:{min:-40, max:40},
  blue:{min:-40, max:40}
};

objects = app.selection;
for (i=0; i<objects.length; i++)
{
  color = objects[i].fillColor;
  if (color instanceof RGBColor)
  {
    r = color.red+adjustRanges.red.min+Math.random()*(adjustRanges.red.max-adjustRanges.red.min);
    if (r < 0) r = 0; if (r > 255) r = 255;

    g = color.green+adjustRanges.green.min+Math.random()*(adjustRanges.green.max-adjustRanges.green.min);
    if (g < 0) g = 0; if (g > 255) g = 255;

    b = color.blue+adjustRanges.blue.min+Math.random()*(adjustRanges.blue.max-adjustRanges.blue.min);
    if (b < 0) b = 0; if (b > 255) b = 255;

    c = new RGBColor();
    c.red = r; c.green = g; c.blue = b;

    objects[i].fillColor = c;
  }
}

Save as "changeColors.jsx" in your local Illustrator's Scripts folder so it will appear in the File > Scripts menu next time you restart Illustrator, or anywhere else (and you'll have to browse for its location).

You can change the min/max adjustment values at will; for example, setting these values to 0 for both red and blue will only change the Green component.

1
  • 2
    +1 you might want to randomize in HSB space though And make the channel randomize a function ;) DRY is after all a thing... yeah i know.
    – joojaa
    Jan 5, 2016 at 11:20
0

There are a couple ways to accomplish randomizing these colors.

Option 1: Randomill

I've made a plugin called Randomill which can accomplish this. You can dial in a range of colors, and all selected objects will have their fill colors randomized from that range.

Randomill's Random Fill Color Illustrator Script

Option 2: Random Swatches Fill Script

Alternatively, there's a free script out there called 'Random Swatches Fill' that can randomize objects' colors from a pre-selected group of swatches. What you could do is create a ton of swatches with varying shades of green and then use this script to randomize the colors of your hexagons.

-4

To get uniform graphics use the snap to grid setting, you can then scale it to your desired size in Illustrator. Check out Chris Spooners blog post about a similar sort of project.

http://blog.spoongraphics.co.uk/tutorials/how-to-create-a-christmas-jumper-pattern-in-illustrator

1
  • Hello and welcome. I dont think he is asking about how to align the hexagons. As that should be easy. Its the changing of the colors bit thats a problem.
    – joojaa
    Jan 5, 2016 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.