Random Color Patterns
Random Color Patterns
Question
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.
Accepted Answer
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.