

Show HN: Distinct Color Palette generator using Red-Yellow-Blue colorspace - friggeri
http://afriggeri.github.com/RYB/

======
MartinCron
This is really great. I wound up doing something like this by hand (by eye?)
the last time I needed to generate a distinct color palette (player colors in
an online map game).

------
mistercow
It would be neat if you could add different color models to optimize for
different kinds of color blindness.

~~~
friggeri
Do you have any reference for that ? (mathematical models of color blindness)
?

~~~
mistercow
This thesis[1] might help as a starting point. It is primarily focused on
simulating colorblindness for the non-colorblind, and gives some
transformations between trichromatic and dichromatic vision.

[1]
[http://www.lume.ufrgs.br/bitstream/handle/10183/26950/000761...](http://www.lume.ufrgs.br/bitstream/handle/10183/26950/000761444.pdf?sequence=1)

------
dredmorbius
Similar concept: I like to be able to generate terminals of varying-but-
viewable color schemes. I'd like to tweak this to use more an HSV than RGB
scheme.

#!/usr/bin/gawk -f

function ranint (x) { return int(rand() * x) } function hex (x) { return
sprintf("%02x", x) }

BEGIN {

    
    
         mc = 96             # max color
    
         # Seed RNG using nanoseconds
         cmd="date +%N"
         cmd | getline seed
         close(cmd)
         srand(seed)
    
         r = ranint(mc)
         g = ranint(mc)
         b = ranint(mc)
         printf( "rxvt -bg \x27#%s%s%s\x27 -fg gold -cr blue &\n", hex(r), hex(g), hex(b) )
     }

------
drv
The "ceiling" symbols (left/right square bracket upper corner) at the
beginning of the explanatory text are displayed as unknown character boxes
here (Win7/Chrome).

~~~
lbotos
I'm not the OP but did a little looking at the source. It's encoded as UTF-8
and is rendering fine in Chrome on Mac. Can someone more experienced with
Character Encoding chime in? I've always wanted to learn more about how things
like this happen. (I assume it's a character encoding issue?)

~~~
friggeri
Not really an encoding problem, I suppose the issue arises because the
fallback font does not have those symbols. I can't test on Windows but if
someone could point me to a font which has those mathematics characters on
Windows I'll gladly specify that font.

~~~
justincormack
The browser is supposed to find a font that does have them in that case, so I
guess no font does. Ssame on iPad.

~~~
lbotos
Can you point me to something that shows this? I know font family declarations
with multiple fonts will fall back but I've never heard of this before. FWIW,
the site only declares one typeface "Lucida Grande" so I assume to browser is
falling back to the default Sans-serif on windows.

~~~
justincormack
It is quoted in various places eg
<http://www.cs.tut.fi/~jkorpela/html/characters.html> although some sources eg
[http://books.google.co.uk/books?id=lxndiWaFMvMC&pg=PA65&...](http://books.google.co.uk/books?id=lxndiWaFMvMC&pg=PA65&lpg=PA65&dq=special+characters+unicode+fallback+browser&source=bl&ots=Nbuu4GQ4EA&sig=06eG-O4LzWsuWMf06QQjn1tKhEA&hl=en&sa=X&ei=cXeIT-6_A4nT0QXF14TMCQ&ved=0CA0Q6AEwAA#v=onepage&q&f=false)
says that IE does not do this. Still looking for original spec though.

------
inconditus
What's pretty cool is that if you generate 1000+ the colors begin to become
muted and look "foresty". Why's this?

~~~
friggeri
Because the colors at the end are the one which are closest to the average of
all those before. In RYB, the average is what you'd obtain by mixing paints of
those colors, so a really earthy tone.

------
malandrew
Why not use CIE L*ab, since that colorimetric system is based on human
perception or difference?

------
jmelloy
Neat. By pure happenstance, I needed a bunch of colors for plots and state
diagrams yesterday.

------
guard-of-terra
I press the generate button and then nothing happens. Firefox here.

~~~
friggeri
Fixed by removing the generate button, it was totally useless anyway as the
update happens directly when you change the number of colors to generate.

~~~
guard-of-terra
I change and change it but nothing happens.

~~~
friggeri
What version of firefox are you running ?

~~~
guard-of-terra
That was 5.0 I guess. It does work on 10.0.

