Author Topic: Choosing a 154 different colors  (Read 2251 times)

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Choosing a 154 different colors
« on: February 28, 2011, 06:47:41 PM »
So I'm working on generating a KML file that shows all our teachers (154 of them) and their students.  I want to color code them but there are a ton.  Any ideas of how to select the colors?  Would like to do it programmatically so that it can expand in the future.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Choosing a 154 different colors
« Reply #1 on: February 28, 2011, 09:25:42 PM »
Evenly distribute them from 0x000000 to 0xFFFFFF ?  I'm not sure if that would produce good results or not. Anyway you go you're bound to end up with some pretty similar colours.

JaWiB

  • definitelys definately no MacGyver
  • Jackass V
  • Posts: 1443
  • Karma: +57/-4
Re: Choosing a 154 different colors
« Reply #2 on: March 01, 2011, 05:44:46 PM »
Can you use something like HSL? I seem to recall that being good to generate a random set of colors. You might start with a hue of zero and increase by certain increments, then increase or decrease saturation or luminance when you get back to 360

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Choosing a 154 different colors
« Reply #3 on: March 01, 2011, 06:16:12 PM »
Can you use something like HSL? I seem to recall that being good to generate a random set of colors. You might start with a hue of zero and increase by certain increments, then increase or decrease saturation or luminance when you get back to 360
IIRC HSL can be converted to RGB.  It does need to be RGB eventually.

PJYelton

  • Power of Voodoo
  • Jackass In Charge
  • Posts: 1597
  • Karma: +56/-12
    • TheRecursiveFractal
Re: Choosing a 154 different colors
« Reply #4 on: March 01, 2011, 06:47:47 PM »
Create a formula that maps their name to a specific color.  Just off the top of my head something like add the char values of the first third of their name and make that the red componant.  Second third add up to the green.  Last third add up to the blue.  Simple example that probably doesn't produce great results but I'm sure with some experimenting you could come up with something better.

Perspective

  • badfish
  • Jackass In Charge
  • Posts: 4635
  • Karma: +64/-22
    • http://jeff.bagu.org
Re: Choosing a 154 different colors
« Reply #5 on: March 01, 2011, 07:38:04 PM »
If you want it to depend on the particular teacher you could hash their name mod 0xFFFFFF and use that as the RGB. Then you can add new teachers but old ones still get the same colour. There's always the possibility of a collision though.

charlie

  • Jackass In Charge
  • Posts: 7903
  • Karma: +84/-53
Re: Choosing a 154 different colors
« Reply #6 on: March 01, 2011, 07:43:51 PM »
Hash table with linear probing if teachers can be added.

Even distribution if teachers are fixed.

:dblthumb2:

JaWiB

  • definitelys definately no MacGyver
  • Jackass V
  • Posts: 1443
  • Karma: +57/-4
Re: Choosing a 154 different colors
« Reply #7 on: March 01, 2011, 08:45:49 PM »
IIRC HSL can be converted to RGB.  It does need to be RGB eventually.
Right. You'd essentially be using the conversion from HSL to RGB as your algorithm. Running through all the different hues guarantees the colors look different (until you get to 360 degrees, at least)

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Choosing a 154 different colors
« Reply #8 on: March 02, 2011, 02:20:35 PM »
If you want it to depend on the particular teacher you could hash their name mod 0xFFFFFF and use that as the RGB. Then you can add new teachers but old ones still get the same colour. There's always the possibility of a collision though.
There really isn't a need to keep a particular teacher the same color.  Only using color to help distinguish one set of teacher/students from another.

Gonna try the HSL thing and see how that works.