Forum Archive

module to generate distinct colors

upwart

Here's a module to generate a specified number of distinct colors.
You can exclude certain colors, most likely black or white by gving a list of color tuples to be excluded.

So for instance:
import distinct_colors
c=distinct_colors.distinct_colors(10,[(0,0,0)])
generates ten distinct colors without using black.

https://gist.github.com/7410aaeb951dc659f8f2

filippocld223

what's the utility? in scene scripts?

upwart

You can use the colors in a scene or canvas script (the main functions shows an example with canvas).
I personnaly developed it to be used in a game (with scene) where I needed a number of colors to be easily distinguized.

filippocld223

Great work :-)

upwart

Here is an update, with improved quality an stability.

https://gist.github.com/ede14e200fbeeb331786