Sunday, April 26, 2009

Consistent Arbitrary Colors

Mibbit gives usernames colors, i think, depending on their users' client. XChat gives everyone but me the same color. I don't like either of these choices because many usernames get the same color, and I therefore can't use color to tell who said something without reading their username.

I'd prefer it if everyone had a different color (to a reasonable extent), but still have the same color the next time they log in. Short of users assigning colors to anything, how could an IRC client accomplish this?

3 comments:

thejoshwolfe said...

here's my solution
http://is.gd/uNl9

Roy van de Water said...

XChat is open source, add it yourself and upload. Or you can write a plugin: http://www.xchat.org/docs/plugin20.html

Andy said...

function hash_to_color (hash) {
divide hash into 3 equal segments
determine the numerical max of a segment
determine the numerical value of each segment

return RGB( value1 / max * 255, value2 / max * 255, value3 / max * 255 )
}