# Repeat colour sequence

Could someone please recommend a method of parametrically adding colours to an array of objects in such a way that the colours could be varied numerically and the pattern could repeat itself over a chosen number. ( eg.repeat c1,c2,c3,c4, c1,c2,c3,c4,)
I know that I could do a bunch of list items with different colours but I wondered if there was a simpler method…
thanks
Giusseppe

Use the modulus component: index_of_element_to_color % color_count = index_of_color
[0 1 2 3 4 5 6] % 3 = [0 1 2 0 1 2 0]

do you mean this modulus ?..not sure how to use it

Btw, you could solve it in many other ways. Like you can use the sequence component. But the modulus solution is most mathematical solution, which is commonly used in programming

Thank you Tom

I saw something like this in a picture once but I could not figure out the expression that was linked to the series…I just guessed with x/3 …it generated nice subtle colours…do you have any idea what it might have been please ?

3_colours_boxes.gh (12.9 KB)

Sounds like you did not understand what I was trying to say. But as long as you found a solution for yourself, then its

Oh no…I understood and applied your method…the other one was from a while ago and didnt work very well because I couldn’t work out the expression. You had mentioned other possible methods and just wondered if you could see what I had missed…I wasnt sure if the same modulus was what I should have used.
thank you again for your help
Giusseppe

sorry, what I wrote didn’t make sense…the modulus is bringing two sets of values together, I see that…what I am wondering is , can an extra input into the numbers ( maybe random) inject colours into the series so that I am not choosing them with swatches?
That way the second list going into modulus would be more interesting than me just choosing the colours.
Generating 4 colours randomly ( or even sequential hues from an initial value) is possible, I suspect…I simply cannot work out how to do it.
I realise that this is more than I initially asked help with. If you could give me a reference that helps I would be grateful.
Giusseppe

I haven’t followed this thread because you posted no code. But the title and this comment make it sound trivial, eh?

colors_2023Sep15b.gh (16.6 KB)

P.S. Random colors:

colors_2023Sep15c.gh (10.6 KB)

thank you Joseph
Together with Tom’s script I now have lots to play with
Giusseppe

Basically the same principle as as @Joseph_Oster 's solution above, random color creation with a couple of controls on luminance and saturation…

PseudoRandomColorSets2.gh (24.7 KB)

Or you could use the color wheel component to create the color sets:

PseudoRandomColorSets3.gh (15.4 KB)

Excellent…thank you all for the input

Tom,
I am so glad that you introduced me to Modulus…it makes combining lists so much easier…

EXPLODED BOX.gh (23.8 KB)