How to Create a Color Palette from set numbers for RGB?

Hello,
I’m posting this in the “General” forum as it’s not strictly a beginner’s question, and probably not necessarily a TD question either, but I feel like maybe it could be done in TD.

I would like to create a Color Palette / Table with only RGB colors containing certain numbers…

For instance if I want to create all the possible colors with the numbers 42 and 66, it would look like:
RGB (66,66,66)
RGB (42,66,66)
RGB (66,42,66)
RGB (66,66,42)
RGB (66,42,42)
RGB (42,42,66)
RGB (42,66,42)
RGB (42,42,42)

Easy enough… now what if there are 11 set numbers instead of just 2?

And ideally the result would be an actual visual color palette or table where it would be easy enough to extract the colors from, so that all the colors used in the project will always be from this set number of colors…

I’m not a coder, and have no idea where to start, maybe TD isn’t the best tool to do this (even though I would eventually want to bring the palette into TD to use it there)…

Any Math enthusiast having any idea?

Thank you.
Damien

Hi Damien,

I think TD is perfect for such a thing
It’s easier to see patterns when you take simpler numbers. If instead of 42 and 66 in your example you would take 0 and 1, the rgb strings will be 000 001 010 011 100 101 110 111… which perhaps you recognize as a binary number system. For example if you would have a 10 set numbers, you just get all 1000 numbers (000 to 999).
So for a 11-base system, you would get 11 * 11 * 11 = 1331 possibilities.

You can use a patternCHOP to make ramps per RGB channel with length 1331 samples. First one looping 11*11 = 121 times, second one looping 11 times and last one just looping once. Then using a lookupCHOP you can lookup the one of the 11 color values.

Perhaps this is a bit tricky to follow, so I made a little example to make things clear.
Hope it helps.

Cheers,
tim

RGBCombinatorics.tox (806 Bytes)

2 Likes

Thank you so much!

That seems really close to what I want, but something isn’t working quite right… I get some gradients which go from one “chosen” color to another… so when I pick whip the colors, some of them have RGB values outside of my set of numbers.
I tried to set the patterns 2 and 3 to square instead of ramp, it worked in that it restricted the colors exactly to my numbers, but then I get repeating colors, which means I don’t have the full 1331 possibilities…

Any ideas?
Thanks
Damien

Hi Damien

ah excuse me, it was quite late yesterday
The lookupCHOP has a ‘interpolate’ toggle which is by default switched on. If you switch that one off,
it looks like it picks the right values.

Cheers,
tim

1 Like

Awesome!

Thank you so much, now on to the fun of using those colors!

Cheers,
Damien

Hi,