I'm trying to draw a picture in tikz whose code is generated by another computer program. The program outputs hundreds of numbers in between 0 and 100, and I'd like to color objects in the picture on a spectrum according to the numbers.
For instance, suppose the spectrum I choose is red-orange-yellow-green-blue-violet. Then I would want to define a macro that has one input (a number between 0 and 100) and gives a color according to the following rules:
0=red
20=orange
40=yellow
60=green
80=blue
100=violet
Any number in between would be an appropriate mix. For example, 5 would be mostly red with a little bit of orange. 55 would be mostly green with a little bit of yellow.
Thank you in advance!
Best Answer
Nested use of
\ifnum
to define a color via\colorlet
does the job:Code: