# How to color elements within Graphics[Table[]] independently?

I've used a Table[] to generate multiple rounded squares, with Rectangle[{m, n}, RoundingRadius -> .35]. So far, I've been able to color all the squares with the same color, for instance, with LightBlue:

Graphics[{EdgeForm[Black], Table[{LightBlue, Rectangle[{m, n}, RoundingRadius -> .35]}, {m, 5}, {n, 5}]}, Frame -> True] Or generate random colors for each square, for instance, with Hue[RandomReal[]]:

Graphics[{EdgeForm[Black], Table[{Hue[RandomReal[]], Rectangle[{m, n}, RoundingRadius -> .35]}, {m, 5}, {n, 5}]}, Frame -> True] But, generally, I'd like to control the color of each of the squares independently, because I already have a vector of Hue[#] colors that I want to use. For instance, I'd like to use this 25 colors in correspondence to each of the (m,n) squares in the grid:

m=5; n=5; Split@Hue[#] & /@ Range[1/(m*n), 1, 1/(m*n)] I've tried to do something like the following, but it doesn't seem right:

Graphics[{EdgeForm[Black], Table[{c, Rectangle[{m, n}, RoundingRadius -> .35]}, {m, 5}, {n, 5}, {c, Split@Hue[#] & /@ Range[1/(m*n), 1, 1/(m*n)]}]}, Frame -> True] I've also tried to Map[] the colors or use a ColorFunction-> but had no success.

I'd appreciate any help, thanks! -Pedro

Starting with slightly modified color code:

m = 5;
n = 5;
colors = Hue /@ Range[1/(m*n), 1, 1/(m*n)];

rectangles = Table[Rectangle[{m, n}, RoundingRadius -> .35], {m, 5}, {n, 5}];


We may use either of these, among others of course:

Graphics[{EdgeForm[Black], {colors, Flatten@rectangles}\[Transpose]}, Frame -> True]

Graphics[{EdgeForm[Black], Riffle[colors, Flatten@rectangles]}, Frame -> True] Reference Transpose and Riffle.

Also possible:

i = 1;

Graphics[{EdgeForm[Black],
Table[{colors[[i++]], Rectangle[{m, n}, RoundingRadius -> .35]}, {m, 5}, {n, 5}]},
Frame -> True]

• Thanks @Mr.Wizard! I wasn't aware of Riffle[]. This is a simple solution :) – TumbiSapichu Feb 18 '18 at 20:09
• @Pedro Glad I could help. – Mr.Wizard Feb 18 '18 at 20:10