I have an array of colors that I need to recursively get every nth element to generate a legend. The colors array might look something like this:
[
'red',
'dark_red',
'dark_dark_red',
'green',
'dark_green',
'dark_dark_green',
'blue',
'dark_blue',
'dark_dark_blue'
]
I have a variable amount of legend items that I want to generate colors for. I want to be able to generate the colors based off of the index when looping through the legend items in a pattern like so:
1 - green
2 - blue
3 - dark_red
4 - dark_green
5 - dark_blue
6 - etc...
How might I go about this? I tried using modulus and a double-loop statement but was not able to generate the colors properly.
ncan be arbitrarily chosen, you can get repeating loops, like if you choose every 3rd element from your 9-item list, you'll just get the 'dark_dark_x' colors. What behavior would you want in that situation?i % amount of colors.