Even More Righteously Bitchin' UPDATE! Current theory is that this works as advertised on any browser that inherits from the old NCSA Mosaic codebase (Mosaic, Spyglass, Netscape, IE, Mozilla, Gecko, and derivatives thereof). Once I got the ball rolling with Ardie (
ardaniel) and the Geek-Out Gang (of which, Constant Readers, I am the least elitest of members), I got grabbed to clean a house and attend a party. After I came home, the latest algorithm failed for name length over twelve, so mad props for Yohimbe to extrapolating pairs to triplets to general-case little letter clusters. Anyway, the real, improved, tested and approved answer to names of more than six characters is below, and it's different from the last one.
So, okay, everyone and their cousin is happily trying the "look what my LJ color is!" thing. I have to admit, I tried it too, and to my complete lack of surprise, I came out a dark blue.
Why lack of surprise? Well, there's the overall metaphysical lack of surprise, but the real non-shocker was because I know how color codes work in HTML... or I thought I did.
Care to be initiated into the mysteries? Then follow... there are some oddball maths within if your relationship to numbers is strictly of the checkbook-balancing variety, but I really do try and explain thoroughly. Oh, and most people wind up on the purple spectrum, somewhere between lavender, magenta, and mauve.
So, okay. Color in HTML is supposed to be handled by a six-digit hexadecimal value. If "hexadecimal" is not in your vocabulary, take a deep breath and count along with me here:
| Hexadecimal (base sixteen) values | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 |
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| Decimal (base ten, i.e. "normal") values | ||||||||||||||||
We're dealing in "base sixteen" here, a topic that may make certain slashlist readers giggle, but there you are. What may be tricker to wrap your mind around is that because hexadecimal "10" is really "sixteen" to decimal reckoning, this means what you learned about hundreds, tens, and ones places in third grade are now the places of "two hundred fifty-sixes," "sixteens" and "ones."
What this has to do with HTML color reckoning is that the normal color declaration is #RRGGBB -- RR, GG, and BB are the red, green, and blue "values" (how much of that primary color is in the shade you desire) for the color you want. RR, GG, and BB are expressed as hexadecimal numbers with a value of 00-FF hex (0-255 decimal) giving 256 possible choices per primary color: 0099FF would mean no red, a little more than half of the possible green, but dammit, turn that blue knob up to eleven!
For curiosity's sake, I should point out that the given example looks like this, a rather charming shade of sky blue.
And what, by Klono's chromium-plated clustered alveoli (woo, someone's been reading the Lensman series again), does this have to do with "look what color my name is!" Easy:
Take a name. We'll start with lwood because it behaves in a way I expect:
lwood
As a color, it's a fetching dark blue that hasn't a prayer of showing up in the default LJ view, so it's just as well as we're behing a cut:
lwood
Now, we take all the letters that aren't valid as hexadecimal numbers out and replace them with zeroes. This means we're only allowed A, B, C, D, E, and F, and all the zeroes we like.
0000d
Behold! And, now that you know the code (put another zero on the end to get a valid RRGGBB sort of number: 0000d0), you too can say, "oh, that's no red, no green, and a generous dollop of blue."
Funky-Fresh Update o' Leetness: M'kay, names of more than six characters are less tricksome than we first thought, now that the code from one of the few open-source inheritors of the codebase has been found, nailed to a wall, and examined thoroughly by Trained Professionals
So, take some long names like mirella, dasubergeek, ardaniel, or clewarahedwi:
mirella
dasubergeek
ardaniel
clewarahedwi
Replace all the unimportant characters with zeroes like before:
000e00a
da0be00ee0
a0da00e0
c0e0a0a0ed00
Count the number of letters in your name and divide by three. If there is a remainder, round UP one number -- so 7-9 character names think 3, 10-12 think 4, 13-15 think 5, and so on. We'll call this number N.
Split your name up into groups of N letters. Why N? Because that's what the code says. We'll get to the twos we need in a minute:
000 e00 a
da00 be00 ee0
a0d a00 e0
c0e0 a0a0 ed00
If the last group of N characters is less than N characters, pad with a zero or two until you have a group of N characters:
000 e00 a00
da00 be00 ee00
a0d a00 e00
c0e0 a0a0 ed00
You should have now only three groups of letters! If not, something is wrong, please check your math.
Almost there! Now take the first two letters from each of your little groups and discard the others, then get rid of the spaces:
00e0a0
dabeee
a0a0e0
c0a0ed
That, darling, is your color, at least as expressed by any browser possessing Mozilla's color-rendering code, and doesn't that look mahvelous on you? Last example:
00e0a0
da0e00
a0a0e0
c0a0d0
Warning: This entire exercise is beyond what the specifications allow for. We're off in that odd part of the map where they used to write Here Be Dragons. Therefore, be aware that while this works most-of-the-time, some names have unusual effects when viewed in one browser or another (e.g. lferion is red in IE, but black in Netscape). We believe this may have to do with characters that don't have more than two significant letters (i.e., ones you didn't change to zeroes) in the first chunk (N-length group) of a word -- in these cases, IE picks from the right, or lops off the first null, or something for names whose length is one more than a multiple of three. Netscape does the exact reverse when the name length is exactly a multiple of three. Names are parsed generally by these rules, but your mileage may otherwise vary, and if it does it's not my fault, Janice's fault, nor Yohimbe's. Go blame AOL and Microsoft for not rewriting the color parser they inherited from the UIUC Supercomputing Center for cripes' sake, which only makes it what, eight years old? Sheesh.
It is granted that this is more useful as an exercise in monitoring genelike activity in progam code than anything else... oh, well, it would also work as a New Age get rich quick/self-help scheme ("Your Name Has a Color! Find Out What It Is!") and if you do Ardaniel and I want a cut, and Yohimbe gets one too.
You'll find some examples here until I make my test page do something else.
-- Lorrie
no subject
Date: 2002-02-08 01:29 pm (UTC)-- L