You probably want to do something else, maybe a color picker ? That is not how it is done. Also, there is no reason to think RGB is restricted to 8 bits per channel (thus limiting to 2^24 colors).
- mmgp
2 Answers
5
votes
Colors are usually represented as hexadecimal numbers which are actually just integers. So a simple loop from 0 to 16,777,215 (0xFFFFFF) would be enough to generate all 24 bit RGB colors.
In python 2.x, you can do:
allcolors = range(0xFFFFFF+1):
5
votes
8-bit RGB values are 3-tuples of numbers 0..255. You can generate them all conveniently using the cartesian product function from itertools.
itertools.product(xrange(256), repeat=3)
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more