We’re going to need a few new concepts to make a colored line figure. Let’s take it in small steps.
A pure function is a function that doesn’t have a name.
This pure function (indicated by # and &) adds 1 to a number:
(# + 1) &[5]
Use the pure function with Map (/@) to add 1 to every number in a list:
(# + 1) & /@ {9, 3, 12}
An equivalent way to write the same thing is to use the function Map instead of the /@ shorthand:
Map[(# + 1) &, {9, 3, 12}]
MapIndexed is like Map. In fact, you get the same result if you use MapIndexed instead of Map:
MapIndexed[(# + 1) &, {9, 3, 12}]
But MapIndexed makes the list position of each element the function is applied to available to the function. Use #2 to get the position:
MapIndexed[{(# + 1), #2} &, {9, 3, 12}]
Use First to extract the position number from the list:
MapIndexed[{(# + 1), First[#2]} &, {9, 3, 12}]
You’ll use the list position to specify the colors of lines in a line figure.
Hue gives different colors for different values between 0 and 1:
Table[Hue[h/10], {h, 0, 10, 1}]
You can use Hue to color objects in Graphics:
Graphics[{Hue[0.8], Line[{{0, 0}, {1, 1}}]}]
Now you have all the concepts you need to color the lines in a figure.
This is the basic figure with black lines:
Graphics[Map[Line, Tuples[CirclePoints[12], 2]]]
Use MapIndexed to color the lines according to their positions in the list. Dividing the Hue value by 12 gives 12 different colors of lines:
Graphics[MapIndexed[{Hue[First[#2]/12], Line[#]} &,
Tuples[CirclePoints[12], 2]]]
Add color to the interactive figure:
Manipulate[
Graphics[MapIndexed[{Hue[First[#2]/n], Line[#]} &,
Tuples[CirclePoints[n], 2]]], {n, 4, 30, 1}]
Manipulate[
Graphics[MapIndexed[{Hue[First[#2]/n], Line[#]} &,
Tuples[CirclePoints[n], 2]]], {n, 4, 30, 1}]