xTerm support...

Posted by Shadowfyr on Thu 05 Apr 2007 07:44 PM — 49 posts, 209,309 views.

USA #0
We where so worried about other things, including MXP, that this slipped under the radar or something. Basically, an application called xTerm supports an extension to ANSI for using 256 colors. The codes work as described here:

http://frexx.de/xterm-256-notes/

Not sure, but I think the colors can be set to anything you want, but there are pre-built sets. In other words, you would need a second "xTerm" color dialog off the one for changing ansi settings, which would bring up the palette you can edit for them all, as well as possibly load a .vim file that has an existing table layout, like those linked to in the page I gave above.

It seems the latest version of TinTin++ now incorporates this feature, as they have combined the code for Putty and TinTin++ into one, and one of them has support for it. This appears to be something that lacks negotiation though. I.e., the client will either support it or not, but the server has no way to tell "if" that feature is supported through the negotiation sequences.

Note: This could probably be handled with the packet intercept and replacement (through simulate) trick, but we should imho limit that, since if everyone "fixes" problems that way, then you start running into "whose" intercept needs to work on the line first, to make sure everything happens as its supposed to, much like problems people are having with more than one plugin using the same line already.

Also, we might want to keep an eye on this:

http://firebolt.com/IMP-rfc.php

They seem to be reinventing MXP there. So far, most of it, except the ones like clearing the text display, which Mushclient can't even do using ANSI codes anyway, appear to be fairly similar to MXP's functions. That might change as they expand the feature set though.
USA #1
What exactly are you suggesting be done about Xterm?

Note that it will be impossible to get full Xterm support without implementing cursor movement support.
USA #2
The only reason I could see to add xterm support would be to have some sort of console version of MUSHclient. Tinyfugue is a console based mud client that I've used on occasion to mud through the ssh program on my cell phone using screen. I'm not even sure if xterm can be used in Windows environments, although someone has probably ported it by now.

If that's not the suggestion, then I believe that Shadowfyr is suggesting that MUSHClient should support 256 colours, which would be a step back from the 16 million it supports now.

Also, although the IMP looks kind of interesting, they have a whole two muds that support it there. Personally, I wouldn't worry about it unless it starts to get more popular, since it seems to be easy to implement as a variation of MXP which calls different functions. The thing that worries me about implementing this is the <AUDIO FILE=filename or URL> and <STOPAUDIO> tags. It just looks like it would take a bit of reworking how MC deals with audio.
Australia Forum Administrator #3
As far as I can see, the 256-colour support (which I had been thinking of) is much simpler than MXP. It basically just allows a wider range of colours to be displayed, without all the hassle of implementing MXP, escaping out ">" signs, and so on.

I've looked, but can't see on the page mentioned above, where the actual mapping is for the 256 codes and the corresponding RGB codes is - can anyone see it?

The problem I think you would have is, that without negotiation, it would be hard to know you could safely send the wider range of colours down to the client. Plus you would need everyone to have a supporting client.

It might be hard to design a colour scheme that supports the existing 16 colors, as well as nicely upgrading to 256 colours.
Australia Forum Administrator #4
There seems to be a chart here:

http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
USA #5
If I remember correctly, xterm-256 is actually not all that well supported. A lot of xterm emulators -- gnome-terminal being the most salient in my mind -- do not support the 256 color mode. And a lot of them have it but as a beta feature, such as SecureCRT for Windows. Anyhow, it would be nice to support the extended color codes, I suppose, but it should be kept in mind that that support is meaningless unless the MUD server knows about it too.



As for a console version of MUSHclient, well, that's a great idea in principle, but the complexity of doing such a thing is mind-boggling to me...
Australia Forum Administrator #6
A question then ...

According to that page, and other resources I found, the 256 colours are introduced with this sequence:


Set the foreground color to index N:   ESC[38;5;Nm
Set the background color to index M:   ESC[48;5;Mm



... where N and M are in the range 0 to 255, and ESC is hex 0x1b.

Now since this is implemented as a state machine, we are taking it one character at a time.

What do we do if we get: ESC[38;6;Nm

That is, something other than 5 after the [38 or [48 ?

USA #7
I'm not sure why this is a problem: if the sequence is one in your list of sequences, you process it, and otherwise you throw it away. (Or, rather, you output it as normal.)

I guess this would require some amount of buffering, and having enough characters of look-ahead before deciding what to print to the screen. Still, this doesn't seem like a big problem to me.

More formally, if you will, if you receive a character that is not part of an expected control sequence, you change to the "normal" state and output the characters. If you are in the normal state and receive a prefix of a control sequence, you keep on trying to parse the control sequence until you reach the end (or fail to), and if you reach the end you do whatever that control sequence calls for.




EDIT:
I imagine the spec should clarify this kind of thing. It's also possible that everything between an ESC and a "m" is ignored if it's not a control sequence, with some kind of limit. I'm sure they say something about this, but I haven't gone to look.
Amended on Fri 06 Apr 2007 03:31 AM by David Haley
Australia Forum Administrator #8
Quote:

I imagine the spec should clarify this kind of thing.


I haven't seen a spec that specifies the 256-colour stuff, I am working from examples.
USA #9
Apparently it doesn't matter if it's 256 or not. The Xterm control codes are apparently of the format specified by ISO 6429, which is "the same" as ECMA 48, according to http://mail.nl.linux.org/linux-utf8/1999-11/msg00173.html.

ECMA 48 may be found here:
http://www.ecma-international.org/publications/standards/Ecma-048.htm

I did not read the whole thing (it's 108 pages and a pretty boring read...), but it would appear that a control sequence is defined precisely as a set of things, and anything you weren't expecting is not a control sequence and therefore meant to be processed as normal data. Therefore as soon as you see something that might be a control sequence, you have to start buffering it until you determine either (a) it is in fact a control sequence or (b) it was not a control sequence (i.e. you saw a number you didn't expect).
Australia Forum Administrator #10
Hmmm.

What I have done in the past is assume that something like:

ESC[xxxm

... is a control sequence, and then if 'xxx' is a recognised number (eg. 41 for red background) switch to that colour, otherwise ignore it.

This, I think, allows for graceful degradation in the event that an unrecognised code appears.

I have got a trial going which seems to work OK, my only query is what do you do if you don't get the final 'm', but instead a semicolon? What part of the sequence do you back track to?

For example, if you wanted colour 124 text on colour 165 background, would it be:


ESC[38;5;124m ESC[48;5;165m   --> presumably that is ok

or:

ESC[38;5;124;48;5;165m   --> backtrack to getting another ANSI code

Amended on Fri 06 Apr 2007 04:48 AM by Nick Gammon
USA #11
I think the standard defines this. Doesn't it allow for lists of command-parameter pairs inside an ESC[ ... m sequence?

Of course, a malicious server could give you an "endless" sequence of correct codes, setting the foreground over and over again, but I'm not sure this is really an issue. At worse, the client can define some arbitrary maximum number of allowed commands in a single sequence in order to not have to keep buffering it all in memory.
Australia Forum Administrator #12
Oh well, my version will accept both of my examples. I personally don't buffer them, the state machine consumes them as it goes.
USA #13
I think both are fine according to the standard. The only reason I see to buffer them is to avoid incorrectly processing an incorrect escape sequence. For instance, if I send ESC[38;5;124;48;5;165j (note terminating j) then the program should not set any colors.
Australia Forum Administrator #14
It looks like you are right, and I am not doing that. Conceivably you could buffer up an indefinite sequence using an STL vector or similar, and then run through it and process everything when you get the 'm', if you ever do.
USA #15
It's something of a pathological case, though. And the "if you ever do" is a problem; the malicious server -- or rather just an incompetent server -- could prevent you from ever seeing more input if for some reason it failed to properly terminate the sequence. Not to mention that it would eventually (after a veeerrrryyy long time) cause some memory issues.
Australia Forum Administrator #16
Quote:

They seem to be reinventing MXP there.


That page was updated in 2002, so I wouldn't worry too much.

They seem to be going down the path of allowing font sizes to be set, and imbedding images in the output window.

It seems to me that, like Pueblo, they aren't sure if they are writing a text MUD client or a web browser.

Like I said before, if you were going to make a custom protocol, I would be concentrating on message types, so the client could omit/show/colour each message (like damage received) as it wanted to.

The whole idea of allowing the server to specify actual colours is a bit wrong-headed, IMHO.

Of course, the 256-colour protocol suffers from the same problem. What happens if you want a different 256 colours?

At least MUSHclient lets you map one colour to another, see:

http://www.gammon.com.au/scripts/doc.php?function=MapColour

You could conceivably map each of the 256 colours to something else, with 256 MapColour commands.
Australia Forum Administrator #17
Quote:

It's something of a pathological case ...


Agreed, and bearing in mind that some server developers don't even both to properly handle '<' symbols even when MXP is active, because zMUD happens to fallback into a mode that displays them, shows that not everyone is really interested in getting things perfect.
Australia Forum Administrator #18
Quote:

Therefore as soon as you see something that might be a control sequence, you have to start buffering it until you determine either (a) it is in fact a control sequence or (b) it was not a control sequence (i.e. you saw a number you didn't expect).

...

For instance, if I send ESC[38;5;124;48;5;165j (note terminating j) then the program should not set any colors.


What if you send ESC[38;5;124;48;5;257;38;5;126m

Note the 257 in the middle is invalid. Should this invalidate the whole sequence? Or just the particular part that can't be processed? I didn't expect 257, but otherwise it looks OK.
Australia Forum Administrator #19
Also, once I see something invalid (like 257 in this case), should I drop back to "display everything" mode? Eg. you would then see on the screen:


38;5;126m


A lot of specs (MXP comes to mind) don't specify exactly how you are to recover if you don't receive what the spec says is "valid".
USA #20
I'm not sure what the correct behavior would be, to be honest. I would guess that the safest thing is to stop parsing the entire sequence as a control sequence.

Specs are nice until they fail to point out certain key elements, as you say...
USA #21
Quote:
The whole idea of allowing the server to specify actual colours is a bit wrong-headed, IMHO.

Of course, the 256-colour protocol suffers from the same problem. What happens if you want a different 256 colours?


Hmm. No reason why you couldn't allow someone to edit it. I assumed that the '.vim' files where mappings. Looks like they are actually used to set the clients colors, based off the default palette. Presumably, you would normally want to leave the grey scale part and the normal ANSI part at defaults (something Mushclient already violates. lol) This is likely a standard palette. I.e., application that export/import 256 color palettes (.pal files) would use the same format for storing their versions.

Note: There seem to be several versions of .pal, though I assume they differ only in what additional things they added, which may not be recognized in other applications. The two most common are probably the IBM spec (search for "Palette File Format"):

http://www.saettler.com/RIFFMCI/riffmci.html

and the one currently in use with Paintshop Pro, the older versions used the same '.pal' type, but now it uses a '.psppalette' file. No idea what the specs on that are.

Its probably not necessary to add support of something like a % of color scale, since while some high def image files do store colors with scales *significantly* higher than 24-bit, but there isn't a display in existence that actually reproduces that level of granularity (yet anyway). The decision to use % in some things like POVRay came from the fact that they where making it possible to generate data "for" those systems that can print or analyze stuff with like 64-bit color or something. lol Scaling an RGB color which has only half the accuracy to something like that causes you to end up with incorrect colors. This is even more true if you try to scale "down" to 8-bit, then back up to some absurd 64-bit standard or something. It just didn't work real well. It was better to provide the original script source and an accurate color table (to within 6 decimal places). Somehow I don't thing we quite need that. lol

Though, it would be nice if we could have an import capability to add additional colors to the color picker list. At least one Linux/Unix based list of web colors I found included about 4-5 times as many, since it allowed for things like "Light Rose 2", "Light Rose", "Dark Rose 2" and "Dark Rose", instead of just "Rose", or even Light and Dark versions only. I.e., there was a scale of at least 4-5 versions of each color, so you could pick a lighter or darker version of them. Its just a thought.

As for IMP. Noticed after posting that they lacked some clear information on some things (even less clear than MXP), so tried to go on their forums. They are all locked, which is when I realized it was entirely a dead system. Forgot to post that here. But I tend to agree with some people discussing it on TMS when talking about client design. There are seriously screwy things in MXP.

Now, with ANSI.. The most common way to handle bad data, in everything I have ever used that had ANSI support, is to just throw out any codes that are invalid. And, I have *never* seen any instance of anyone using multiple codes in each sequence. Most of the books I ever read on the subject, while never explicit about it, seemed to imply that you have to set foreground and background *independently*. I have no idea if that is in fact the case or not, but I would be surprised if someplace there wasn't something saying so.
USA #22
Quote:
And, I have *never* seen any instance of anyone using multiple codes in each sequence. Most of the books I ever read on the subject, while never explicit about it, seemed to imply that you have to set foreground and background *independently*.
Keep in mind that there are different specs on this. The normal ANSI spec doesn't handle anything beyond the 8 colors (with bright or bold flags). The xterm spec explicitly allows for multiple values.

See:
http://rtfm.etla.org/xterm/ctlseq.html
and search for "CSI Pm m"
Note that "Pm" is defined as:
"A multiple numeric parameter composed of any number of single numeric parameters, separated by ; character(s). Individual values for the parameters are listed with Ps."
Australia Forum Administrator #23
Quote:

... and the normal ANSI part at defaults (something Mushclient already violates. lol)


In what way?

Quote:

No reason why you couldn't allow someone to edit it.


I suppose, but remember the idea here is not to render photographs. With a gradual range of 6 * 6 * 6 colours, you should be able to represent almost any colour that the eye can distinguish easily enough, and it would confuse things if a particular server required a different client mapping.

However as I noted, if a particular choice of colours by the server designer annoyed you, you could use the internal colour mapping to replace it.
USA #24
Quote:
No reason why you couldn't allow someone to edit it. I assumed that the '.vim' files where mappings. Looks like they are actually used to set the clients colors, based off the default palette.

Vim is a text editor which is Vi IMproved. The .vim files are colour schemes for the editor. The screenshot just above all the .vim files is a screenshot of someone using vim to edit some code. It has nothing to do with a mud client whatsoever. These assumptions you make are what gets you into trouble. Please do some research first.

Quote:
Though, it would be nice if we could have an import capability to add additional colors to the color picker list. At least one Linux/Unix based list of web colors I found included about 4-5 times as many, since it allowed for things like "Light Rose 2", "Light Rose", "Dark Rose 2" and "Dark Rose", instead of just "Rose", or even Light and Dark versions only. I.e., there was a scale of at least 4-5 versions of each color, so you could pick a lighter or darker version of them. Its just a thought.

Exactly how many colours can we possibly need in a colour picker? The one that MUSHclient uses has this lovely "Other colour" button which pops up a nice little menu where you can click on the colour you want. Much easier than scanning down an insane list of colour names, which can vary from program to program since there is no real standard for them. Also, if you're worried about scripts or something, an rgb value will take up less space and leave no room for creative interpretation.

As for anything else dealing with colour, keep in mind that the human eye can distinguish roughly 10 million colours, most of which people will only notice if they have two large bands of both colours right next to each other. The only reason to have a number of colours higher than that for anything would be photographs and video, since it allows for smoother transitioning. That is most certainly not needed for text, but very necessary for programs like POVray.

But once again, with MUSHclient being open source now. Feel free to add whatever functionality you want.
Australia Forum Administrator #25
Quote:

Exactly how many colours can we possibly need in a colour picker?


I am inclined to agree with Shaun here. It is all very well wanting 500 colours in the picker, but it then gets unwieldy.

It is very easy to choose a colour like "powderblue" and then adjust the RGB sliders to modify the colour slightly, or click "other colour" to open the standard Windows colour picker, and then move the luminance slider, if you want to change the brightness of it.

Again, for a text-based MUD output, you want fairly distinct colours anyway. If a mob is dangerous, it needs to have its name in red, you don't want some subtle colour distinctions where "brown" is a safe mob and "firebrick" (which looks almost identical to me), is unsafe.

In fact, MUSHclient's colour picker shows 140 colours, which is probably a pretty reasonable range.
Australia Forum Administrator #26
Inverse behaviour?

What behaviour would you expect if the colours are inverted?

eg. given that:


ESC[38;5;9m --> red text
ESC[48;5;10m --> green background
ESC[7m --> inverse


If I get:


ESC[38;5;9m test ESC[48;5;10m


Then I expect to see "test" in red text on green background.

But what about:


ESC[7m ESC[38;5;9m test ESC[48;5;10m


Do I see red on green still? Or is it inverted so it is green on red?


Australia Forum Administrator #27
Can anyone confirm these are the "official" colours for this new xTerm sequence?


0 (black)                 R=  0 G=  0 B=  0 #000000 &h000000 0x000000 
1 (maroon)                R=128 G=  0 B=  0 #800000 &h000080 0x000080 
2 (green)                 R=  0 G=128 B=  0 #008000 &h008000 0x008000 
3 (olive)                 R=128 G=128 B=  0 #808000 &h008080 0x008080 
4 (navy)                  R=  0 G=  0 B=128 #000080 &h800000 0x800000 
5 (purple)                R=128 G=  0 B=128 #800080 &h800080 0x800080 
6 (teal)                  R=  0 G=128 B=128 #008080 &h808000 0x808000 
7 (silver)                R=192 G=192 B=192 #C0C0C0 &hC0C0C0 0xC0C0C0 
8 (gray)                  R=128 G=128 B=128 #808080 &h808080 0x808080 
9 (red)                   R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 
10 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 
11 (yellow)               R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 
12 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 
13 (magenta, fuchsia)     R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 
14 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 
15 (white)                R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 
16 (black)                R=  0 G=  0 B=  0 #000000 &h000000 0x000000 
17                        R=  0 G=  0 B= 95 #00005F &h5F0000 0x5F0000 
18                        R=  0 G=  0 B=135 #000087 &h870000 0x870000 
19                        R=  0 G=  0 B=175 #0000AF &hAF0000 0xAF0000 
20                        R=  0 G=  0 B=223 #0000DF &hDF0000 0xDF0000 
21 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 
22                        R=  0 G= 95 B=  0 #005F00 &h005F00 0x005F00 
23                        R=  0 G= 95 B= 95 #005F5F &h5F5F00 0x5F5F00 
24                        R=  0 G= 95 B=135 #005F87 &h875F00 0x875F00 
25                        R=  0 G= 95 B=175 #005FAF &hAF5F00 0xAF5F00 
26                        R=  0 G= 95 B=223 #005FDF &hDF5F00 0xDF5F00 
27                        R=  0 G= 95 B=255 #005FFF &hFF5F00 0xFF5F00 
28                        R=  0 G=135 B=  0 #008700 &h008700 0x008700 
29                        R=  0 G=135 B= 95 #00875F &h5F8700 0x5F8700 
30                        R=  0 G=135 B=135 #008787 &h878700 0x878700 
31                        R=  0 G=135 B=175 #0087AF &hAF8700 0xAF8700 
32                        R=  0 G=135 B=223 #0087DF &hDF8700 0xDF8700 
33                        R=  0 G=135 B=255 #0087FF &hFF8700 0xFF8700 
34                        R=  0 G=175 B=  0 #00AF00 &h00AF00 0x00AF00 
35                        R=  0 G=175 B= 95 #00AF5F &h5FAF00 0x5FAF00 
36                        R=  0 G=175 B=135 #00AF87 &h87AF00 0x87AF00 
37                        R=  0 G=175 B=175 #00AFAF &hAFAF00 0xAFAF00 
38                        R=  0 G=175 B=223 #00AFDF &hDFAF00 0xDFAF00 
39                        R=  0 G=175 B=255 #00AFFF &hFFAF00 0xFFAF00 
40                        R=  0 G=223 B=  0 #00DF00 &h00DF00 0x00DF00 
41                        R=  0 G=223 B= 95 #00DF5F &h5FDF00 0x5FDF00 
42                        R=  0 G=223 B=135 #00DF87 &h87DF00 0x87DF00 
43                        R=  0 G=223 B=175 #00DFAF &hAFDF00 0xAFDF00 
44                        R=  0 G=223 B=223 #00DFDF &hDFDF00 0xDFDF00 
45                        R=  0 G=223 B=255 #00DFFF &hFFDF00 0xFFDF00 
46 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 
47                        R=  0 G=255 B= 95 #00FF5F &h5FFF00 0x5FFF00 
48                        R=  0 G=255 B=135 #00FF87 &h87FF00 0x87FF00 
49                        R=  0 G=255 B=175 #00FFAF &hAFFF00 0xAFFF00 
50                        R=  0 G=255 B=223 #00FFDF &hDFFF00 0xDFFF00 
51 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 
52                        R= 95 G=  0 B=  0 #5F0000 &h00005F 0x00005F 
53                        R= 95 G=  0 B= 95 #5F005F &h5F005F 0x5F005F 
54                        R= 95 G=  0 B=135 #5F0087 &h87005F 0x87005F 
55                        R= 95 G=  0 B=175 #5F00AF &hAF005F 0xAF005F 
56                        R= 95 G=  0 B=223 #5F00DF &hDF005F 0xDF005F 
57                        R= 95 G=  0 B=255 #5F00FF &hFF005F 0xFF005F 
58                        R= 95 G= 95 B=  0 #5F5F00 &h005F5F 0x005F5F 
59                        R= 95 G= 95 B= 95 #5F5F5F &h5F5F5F 0x5F5F5F 
60                        R= 95 G= 95 B=135 #5F5F87 &h875F5F 0x875F5F 
61                        R= 95 G= 95 B=175 #5F5FAF &hAF5F5F 0xAF5F5F 
62                        R= 95 G= 95 B=223 #5F5FDF &hDF5F5F 0xDF5F5F 
63                        R= 95 G= 95 B=255 #5F5FFF &hFF5F5F 0xFF5F5F 
64                        R= 95 G=135 B=  0 #5F8700 &h00875F 0x00875F 
65                        R= 95 G=135 B= 95 #5F875F &h5F875F 0x5F875F 
66                        R= 95 G=135 B=135 #5F8787 &h87875F 0x87875F 
67                        R= 95 G=135 B=175 #5F87AF &hAF875F 0xAF875F 
68                        R= 95 G=135 B=223 #5F87DF &hDF875F 0xDF875F 
69                        R= 95 G=135 B=255 #5F87FF &hFF875F 0xFF875F 
70                        R= 95 G=175 B=  0 #5FAF00 &h00AF5F 0x00AF5F 
71                        R= 95 G=175 B= 95 #5FAF5F &h5FAF5F 0x5FAF5F 
72                        R= 95 G=175 B=135 #5FAF87 &h87AF5F 0x87AF5F 
73                        R= 95 G=175 B=175 #5FAFAF &hAFAF5F 0xAFAF5F 
74                        R= 95 G=175 B=223 #5FAFDF &hDFAF5F 0xDFAF5F 
75                        R= 95 G=175 B=255 #5FAFFF &hFFAF5F 0xFFAF5F 
76                        R= 95 G=223 B=  0 #5FDF00 &h00DF5F 0x00DF5F 
77                        R= 95 G=223 B= 95 #5FDF5F &h5FDF5F 0x5FDF5F 
78                        R= 95 G=223 B=135 #5FDF87 &h87DF5F 0x87DF5F 
79                        R= 95 G=223 B=175 #5FDFAF &hAFDF5F 0xAFDF5F 
80                        R= 95 G=223 B=223 #5FDFDF &hDFDF5F 0xDFDF5F 
81                        R= 95 G=223 B=255 #5FDFFF &hFFDF5F 0xFFDF5F 
82                        R= 95 G=255 B=  0 #5FFF00 &h00FF5F 0x00FF5F 
83                        R= 95 G=255 B= 95 #5FFF5F &h5FFF5F 0x5FFF5F 
84                        R= 95 G=255 B=135 #5FFF87 &h87FF5F 0x87FF5F 
85                        R= 95 G=255 B=175 #5FFFAF &hAFFF5F 0xAFFF5F 
86                        R= 95 G=255 B=223 #5FFFDF &hDFFF5F 0xDFFF5F 
87                        R= 95 G=255 B=255 #5FFFFF &hFFFF5F 0xFFFF5F 
88                        R=135 G=  0 B=  0 #870000 &h000087 0x000087 
89                        R=135 G=  0 B= 95 #87005F &h5F0087 0x5F0087 
90                        R=135 G=  0 B=135 #870087 &h870087 0x870087 
91                        R=135 G=  0 B=175 #8700AF &hAF0087 0xAF0087 
92                        R=135 G=  0 B=223 #8700DF &hDF0087 0xDF0087 
93                        R=135 G=  0 B=255 #8700FF &hFF0087 0xFF0087 
94                        R=135 G= 95 B=  0 #875F00 &h005F87 0x005F87 
95                        R=135 G= 95 B= 95 #875F5F &h5F5F87 0x5F5F87 
96                        R=135 G= 95 B=135 #875F87 &h875F87 0x875F87 
97                        R=135 G= 95 B=175 #875FAF &hAF5F87 0xAF5F87 
98                        R=135 G= 95 B=223 #875FDF &hDF5F87 0xDF5F87 
99                        R=135 G= 95 B=255 #875FFF &hFF5F87 0xFF5F87 
100                       R=135 G=135 B=  0 #878700 &h008787 0x008787 
101                       R=135 G=135 B= 95 #87875F &h5F8787 0x5F8787 
102                       R=135 G=135 B=135 #878787 &h878787 0x878787 
103                       R=135 G=135 B=175 #8787AF &hAF8787 0xAF8787 
104                       R=135 G=135 B=223 #8787DF &hDF8787 0xDF8787 
105                       R=135 G=135 B=255 #8787FF &hFF8787 0xFF8787 
106                       R=135 G=175 B=  0 #87AF00 &h00AF87 0x00AF87 
107                       R=135 G=175 B= 95 #87AF5F &h5FAF87 0x5FAF87 
108                       R=135 G=175 B=135 #87AF87 &h87AF87 0x87AF87 
109                       R=135 G=175 B=175 #87AFAF &hAFAF87 0xAFAF87 
110                       R=135 G=175 B=223 #87AFDF &hDFAF87 0xDFAF87 
111                       R=135 G=175 B=255 #87AFFF &hFFAF87 0xFFAF87 
112                       R=135 G=223 B=  0 #87DF00 &h00DF87 0x00DF87 
113                       R=135 G=223 B= 95 #87DF5F &h5FDF87 0x5FDF87 
114                       R=135 G=223 B=135 #87DF87 &h87DF87 0x87DF87 
115                       R=135 G=223 B=175 #87DFAF &hAFDF87 0xAFDF87 
116                       R=135 G=223 B=223 #87DFDF &hDFDF87 0xDFDF87 
117                       R=135 G=223 B=255 #87DFFF &hFFDF87 0xFFDF87 
118                       R=135 G=255 B=  0 #87FF00 &h00FF87 0x00FF87 
119                       R=135 G=255 B= 95 #87FF5F &h5FFF87 0x5FFF87 
120                       R=135 G=255 B=135 #87FF87 &h87FF87 0x87FF87 
121                       R=135 G=255 B=175 #87FFAF &hAFFF87 0xAFFF87 
122                       R=135 G=255 B=223 #87FFDF &hDFFF87 0xDFFF87 
123                       R=135 G=255 B=255 #87FFFF &hFFFF87 0xFFFF87 
124                       R=175 G=  0 B=  0 #AF0000 &h0000AF 0x0000AF 
125                       R=175 G=  0 B= 95 #AF005F &h5F00AF 0x5F00AF 
126                       R=175 G=  0 B=135 #AF0087 &h8700AF 0x8700AF 
127                       R=175 G=  0 B=175 #AF00AF &hAF00AF 0xAF00AF 
128                       R=175 G=  0 B=223 #AF00DF &hDF00AF 0xDF00AF 
129                       R=175 G=  0 B=255 #AF00FF &hFF00AF 0xFF00AF 
130                       R=175 G= 95 B=  0 #AF5F00 &h005FAF 0x005FAF 
131                       R=175 G= 95 B= 95 #AF5F5F &h5F5FAF 0x5F5FAF 
132                       R=175 G= 95 B=135 #AF5F87 &h875FAF 0x875FAF 
133                       R=175 G= 95 B=175 #AF5FAF &hAF5FAF 0xAF5FAF 
134                       R=175 G= 95 B=223 #AF5FDF &hDF5FAF 0xDF5FAF 
135                       R=175 G= 95 B=255 #AF5FFF &hFF5FAF 0xFF5FAF 
136                       R=175 G=135 B=  0 #AF8700 &h0087AF 0x0087AF 
137                       R=175 G=135 B= 95 #AF875F &h5F87AF 0x5F87AF 
138                       R=175 G=135 B=135 #AF8787 &h8787AF 0x8787AF 
139                       R=175 G=135 B=175 #AF87AF &hAF87AF 0xAF87AF 
140                       R=175 G=135 B=223 #AF87DF &hDF87AF 0xDF87AF 
141                       R=175 G=135 B=255 #AF87FF &hFF87AF 0xFF87AF 
142                       R=175 G=175 B=  0 #AFAF00 &h00AFAF 0x00AFAF 
143                       R=175 G=175 B= 95 #AFAF5F &h5FAFAF 0x5FAFAF 
144                       R=175 G=175 B=135 #AFAF87 &h87AFAF 0x87AFAF 
145                       R=175 G=175 B=175 #AFAFAF &hAFAFAF 0xAFAFAF 
146                       R=175 G=175 B=223 #AFAFDF &hDFAFAF 0xDFAFAF 
147                       R=175 G=175 B=255 #AFAFFF &hFFAFAF 0xFFAFAF 
148                       R=175 G=223 B=  0 #AFDF00 &h00DFAF 0x00DFAF 
149                       R=175 G=223 B= 95 #AFDF5F &h5FDFAF 0x5FDFAF 
150                       R=175 G=223 B=135 #AFDF87 &h87DFAF 0x87DFAF 
151                       R=175 G=223 B=175 #AFDFAF &hAFDFAF 0xAFDFAF 
152                       R=175 G=223 B=223 #AFDFDF &hDFDFAF 0xDFDFAF 
153                       R=175 G=223 B=255 #AFDFFF &hFFDFAF 0xFFDFAF 
154                       R=175 G=255 B=  0 #AFFF00 &h00FFAF 0x00FFAF 
155                       R=175 G=255 B= 95 #AFFF5F &h5FFFAF 0x5FFFAF 
156                       R=175 G=255 B=135 #AFFF87 &h87FFAF 0x87FFAF 
157                       R=175 G=255 B=175 #AFFFAF &hAFFFAF 0xAFFFAF 
158                       R=175 G=255 B=223 #AFFFDF &hDFFFAF 0xDFFFAF 
159                       R=175 G=255 B=255 #AFFFFF &hFFFFAF 0xFFFFAF 
160                       R=223 G=  0 B=  0 #DF0000 &h0000DF 0x0000DF 
161                       R=223 G=  0 B= 95 #DF005F &h5F00DF 0x5F00DF 
162                       R=223 G=  0 B=135 #DF0087 &h8700DF 0x8700DF 
163                       R=223 G=  0 B=175 #DF00AF &hAF00DF 0xAF00DF 
164                       R=223 G=  0 B=223 #DF00DF &hDF00DF 0xDF00DF 
165                       R=223 G=  0 B=255 #DF00FF &hFF00DF 0xFF00DF 
166                       R=223 G= 95 B=  0 #DF5F00 &h005FDF 0x005FDF 
167                       R=223 G= 95 B= 95 #DF5F5F &h5F5FDF 0x5F5FDF 
168                       R=223 G= 95 B=135 #DF5F87 &h875FDF 0x875FDF 
169                       R=223 G= 95 B=175 #DF5FAF &hAF5FDF 0xAF5FDF 
170                       R=223 G= 95 B=223 #DF5FDF &hDF5FDF 0xDF5FDF 
171                       R=223 G= 95 B=255 #DF5FFF &hFF5FDF 0xFF5FDF 
172                       R=223 G=135 B=  0 #DF8700 &h0087DF 0x0087DF 
173                       R=223 G=135 B= 95 #DF875F &h5F87DF 0x5F87DF 
174                       R=223 G=135 B=135 #DF8787 &h8787DF 0x8787DF 
175                       R=223 G=135 B=175 #DF87AF &hAF87DF 0xAF87DF 
176                       R=223 G=135 B=223 #DF87DF &hDF87DF 0xDF87DF 
177                       R=223 G=135 B=255 #DF87FF &hFF87DF 0xFF87DF 
178                       R=223 G=175 B=  0 #DFAF00 &h00AFDF 0x00AFDF 
179                       R=223 G=175 B= 95 #DFAF5F &h5FAFDF 0x5FAFDF 
180                       R=223 G=175 B=135 #DFAF87 &h87AFDF 0x87AFDF 
181                       R=223 G=175 B=175 #DFAFAF &hAFAFDF 0xAFAFDF 
182                       R=223 G=175 B=223 #DFAFDF &hDFAFDF 0xDFAFDF 
183                       R=223 G=175 B=255 #DFAFFF &hFFAFDF 0xFFAFDF 
184                       R=223 G=223 B=  0 #DFDF00 &h00DFDF 0x00DFDF 
185                       R=223 G=223 B= 95 #DFDF5F &h5FDFDF 0x5FDFDF 
186                       R=223 G=223 B=135 #DFDF87 &h87DFDF 0x87DFDF 
187                       R=223 G=223 B=175 #DFDFAF &hAFDFDF 0xAFDFDF 
188                       R=223 G=223 B=223 #DFDFDF &hDFDFDF 0xDFDFDF 
189                       R=223 G=223 B=255 #DFDFFF &hFFDFDF 0xFFDFDF 
190                       R=223 G=255 B=  0 #DFFF00 &h00FFDF 0x00FFDF 
191                       R=223 G=255 B= 95 #DFFF5F &h5FFFDF 0x5FFFDF 
192                       R=223 G=255 B=135 #DFFF87 &h87FFDF 0x87FFDF 
193                       R=223 G=255 B=175 #DFFFAF &hAFFFDF 0xAFFFDF 
194                       R=223 G=255 B=223 #DFFFDF &hDFFFDF 0xDFFFDF 
195                       R=223 G=255 B=255 #DFFFFF &hFFFFDF 0xFFFFDF 
196 (red)                 R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 
197                       R=255 G=  0 B= 95 #FF005F &h5F00FF 0x5F00FF 
198                       R=255 G=  0 B=135 #FF0087 &h8700FF 0x8700FF 
199                       R=255 G=  0 B=175 #FF00AF &hAF00FF 0xAF00FF 
200                       R=255 G=  0 B=223 #FF00DF &hDF00FF 0xDF00FF 
201 (magenta, fuchsia)    R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 
202                       R=255 G= 95 B=  0 #FF5F00 &h005FFF 0x005FFF 
203                       R=255 G= 95 B= 95 #FF5F5F &h5F5FFF 0x5F5FFF 
204                       R=255 G= 95 B=135 #FF5F87 &h875FFF 0x875FFF 
205                       R=255 G= 95 B=175 #FF5FAF &hAF5FFF 0xAF5FFF 
206                       R=255 G= 95 B=223 #FF5FDF &hDF5FFF 0xDF5FFF 
207                       R=255 G= 95 B=255 #FF5FFF &hFF5FFF 0xFF5FFF 
208                       R=255 G=135 B=  0 #FF8700 &h0087FF 0x0087FF 
209                       R=255 G=135 B= 95 #FF875F &h5F87FF 0x5F87FF 
210                       R=255 G=135 B=135 #FF8787 &h8787FF 0x8787FF 
211                       R=255 G=135 B=175 #FF87AF &hAF87FF 0xAF87FF 
212                       R=255 G=135 B=223 #FF87DF &hDF87FF 0xDF87FF 
213                       R=255 G=135 B=255 #FF87FF &hFF87FF 0xFF87FF 
214                       R=255 G=175 B=  0 #FFAF00 &h00AFFF 0x00AFFF 
215                       R=255 G=175 B= 95 #FFAF5F &h5FAFFF 0x5FAFFF 
216                       R=255 G=175 B=135 #FFAF87 &h87AFFF 0x87AFFF 
217                       R=255 G=175 B=175 #FFAFAF &hAFAFFF 0xAFAFFF 
218                       R=255 G=175 B=223 #FFAFDF &hDFAFFF 0xDFAFFF 
219                       R=255 G=175 B=255 #FFAFFF &hFFAFFF 0xFFAFFF 
220                       R=255 G=223 B=  0 #FFDF00 &h00DFFF 0x00DFFF 
221                       R=255 G=223 B= 95 #FFDF5F &h5FDFFF 0x5FDFFF 
222                       R=255 G=223 B=135 #FFDF87 &h87DFFF 0x87DFFF 
223                       R=255 G=223 B=175 #FFDFAF &hAFDFFF 0xAFDFFF 
224                       R=255 G=223 B=223 #FFDFDF &hDFDFFF 0xDFDFFF 
225                       R=255 G=223 B=255 #FFDFFF &hFFDFFF 0xFFDFFF 
226 (yellow)              R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 
227                       R=255 G=255 B= 95 #FFFF5F &h5FFFFF 0x5FFFFF 
228                       R=255 G=255 B=135 #FFFF87 &h87FFFF 0x87FFFF 
229                       R=255 G=255 B=175 #FFFFAF &hAFFFFF 0xAFFFFF 
230                       R=255 G=255 B=223 #FFFFDF &hDFFFFF 0xDFFFFF 
231 (white)               R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 
232                       R=  8 G=  8 B=  8 #080808 &h080808 0x080808 
233                       R= 18 G= 18 B= 18 #121212 &h121212 0x121212 
234                       R= 28 G= 28 B= 28 #1C1C1C &h1C1C1C 0x1C1C1C 
235                       R= 38 G= 38 B= 38 #262626 &h262626 0x262626 
236                       R= 48 G= 48 B= 48 #303030 &h303030 0x303030 
237                       R= 58 G= 58 B= 58 #3A3A3A &h3A3A3A 0x3A3A3A 
238                       R= 68 G= 68 B= 68 #444444 &h444444 0x444444 
239                       R= 78 G= 78 B= 78 #4E4E4E &h4E4E4E 0x4E4E4E 
240                       R= 88 G= 88 B= 88 #585858 &h585858 0x585858 
241                       R= 98 G= 98 B= 98 #626262 &h626262 0x626262 
242                       R=108 G=108 B=108 #6C6C6C &h6C6C6C 0x6C6C6C 
243                       R=118 G=118 B=118 #767676 &h767676 0x767676 
244 (gray)                R=128 G=128 B=128 #808080 &h808080 0x808080 
245                       R=138 G=138 B=138 #8A8A8A &h8A8A8A 0x8A8A8A 
246                       R=148 G=148 B=148 #949494 &h949494 0x949494 
247                       R=158 G=158 B=158 #9E9E9E &h9E9E9E 0x9E9E9E 
248                       R=168 G=168 B=168 #A8A8A8 &hA8A8A8 0xA8A8A8 
249                       R=178 G=178 B=178 #B2B2B2 &hB2B2B2 0xB2B2B2 
250                       R=188 G=188 B=188 #BCBCBC &hBCBCBC 0xBCBCBC 
251                       R=198 G=198 B=198 #C6C6C6 &hC6C6C6 0xC6C6C6 
252                       R=208 G=208 B=208 #D0D0D0 &hD0D0D0 0xD0D0D0 
253                       R=218 G=218 B=218 #DADADA &hDADADA 0xDADADA 
254                       R=228 G=228 B=228 #E4E4E4 &hE4E4E4 0xE4E4E4 
255                       R=238 G=238 B=238 #EEEEEE &hEEEEEE 0xEEEEEE 


I am assuming the first 16 are OK, as they are identical to the standard 16-colour ANSI values. Also the grey scale ones (232 onwards) seem reasonable as they go up in a standard way.

I am not sure about the 6 * 6 * 6 colour cube. This is the algorithm I am using:


  int red, green, blue;
  const BYTE values [6] = { 0x00, 0x5F, 0x87, 0xAF, 0xDF, 0xFF };

  for (red = 0; red < 6; red++)
    for (green = 0; green < 6; green++)
      for (blue = 0; blue < 6; blue++)
         xterm_256_colours [16 + (red * 36) + (blue * 6) + green] =
            RGB (values [red], values [blue], values [green]);


  int grey;
  for (grey = 0; grey < 24; grey++)
    {
    BYTE value = 8 + (grey * 10);
    xterm_256_colours [232 + grey] = RGB (value, value, value);
    }


The thing that concerns me here is that the gaps in the colour cube (ie. the "values" table) are not evenly spaced.

However they give a result that is consistent with the only web page I found so far that actually listed RGB values. That is:

http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html

Is this correct? Or just someone's personal preference?
Amended on Sat 07 Apr 2007 02:48 AM by Nick Gammon
Australia Forum Administrator #28
Another site I came across seems to suggest that the colours *should* be evenly spaced in the colour cube, by an amount of 42.5 (ie. 256 / 6) rather than the spacing given on the page above.

The spacing in the current algorithm is:

95 + 40 + 40 + 48 + 32 = 255


An alternate algorithm, based on the 42.5 gap, would be:


  for (red = 0; red < 6; red++)
      for (green = 0; green < 6; green++)
        for (blue = 0; blue < 6; blue++)
           xterm_256_colours [16 + (red * 36) + (blue * 6) + green] =
              RGB (red * 42.5, blue * 42.5, green * 42.5);

Amended on Sat 07 Apr 2007 02:57 AM by Nick Gammon
Australia Forum Administrator #29
Using that second approach gave these results, which look a bit darker:


16 (black)                R=  0 G=  0 B=  0 #000000 &h000000 0x000000 
17                        R=  0 G=  0 B= 42 #00002A &h2A0000 0x2A0000 
18                        R=  0 G=  0 B= 85 #000055 &h550000 0x550000 
19                        R=  0 G=  0 B=127 #00007F &h7F0000 0x7F0000 
20                        R=  0 G=  0 B=170 #0000AA &hAA0000 0xAA0000 
21                        R=  0 G=  0 B=212 #0000D4 &hD40000 0xD40000 
22                        R=  0 G= 42 B=  0 #002A00 &h002A00 0x002A00 
23                        R=  0 G= 42 B= 42 #002A2A &h2A2A00 0x2A2A00 
24                        R=  0 G= 42 B= 85 #002A55 &h552A00 0x552A00 
25                        R=  0 G= 42 B=127 #002A7F &h7F2A00 0x7F2A00 
26                        R=  0 G= 42 B=170 #002AAA &hAA2A00 0xAA2A00 
27                        R=  0 G= 42 B=212 #002AD4 &hD42A00 0xD42A00 
28                        R=  0 G= 85 B=  0 #005500 &h005500 0x005500 
29                        R=  0 G= 85 B= 42 #00552A &h2A5500 0x2A5500 
30                        R=  0 G= 85 B= 85 #005555 &h555500 0x555500 
31                        R=  0 G= 85 B=127 #00557F &h7F5500 0x7F5500 
32                        R=  0 G= 85 B=170 #0055AA &hAA5500 0xAA5500 
33                        R=  0 G= 85 B=212 #0055D4 &hD45500 0xD45500 
34                        R=  0 G=127 B=  0 #007F00 &h007F00 0x007F00 
35                        R=  0 G=127 B= 42 #007F2A &h2A7F00 0x2A7F00 
36                        R=  0 G=127 B= 85 #007F55 &h557F00 0x557F00 
37                        R=  0 G=127 B=127 #007F7F &h7F7F00 0x7F7F00 
38                        R=  0 G=127 B=170 #007FAA &hAA7F00 0xAA7F00 
39                        R=  0 G=127 B=212 #007FD4 &hD47F00 0xD47F00 
40                        R=  0 G=170 B=  0 #00AA00 &h00AA00 0x00AA00 
41                        R=  0 G=170 B= 42 #00AA2A &h2AAA00 0x2AAA00 
42                        R=  0 G=170 B= 85 #00AA55 &h55AA00 0x55AA00 
43                        R=  0 G=170 B=127 #00AA7F &h7FAA00 0x7FAA00 
44                        R=  0 G=170 B=170 #00AAAA &hAAAA00 0xAAAA00 
45                        R=  0 G=170 B=212 #00AAD4 &hD4AA00 0xD4AA00 
46                        R=  0 G=212 B=  0 #00D400 &h00D400 0x00D400 
47                        R=  0 G=212 B= 42 #00D42A &h2AD400 0x2AD400 
48                        R=  0 G=212 B= 85 #00D455 &h55D400 0x55D400 
49                        R=  0 G=212 B=127 #00D47F &h7FD400 0x7FD400 
50                        R=  0 G=212 B=170 #00D4AA &hAAD400 0xAAD400 
51                        R=  0 G=212 B=212 #00D4D4 &hD4D400 0xD4D400 
52                        R= 42 G=  0 B=  0 #2A0000 &h00002A 0x00002A 
53                        R= 42 G=  0 B= 42 #2A002A &h2A002A 0x2A002A 
54                        R= 42 G=  0 B= 85 #2A0055 &h55002A 0x55002A 
55                        R= 42 G=  0 B=127 #2A007F &h7F002A 0x7F002A 
56                        R= 42 G=  0 B=170 #2A00AA &hAA002A 0xAA002A 
57                        R= 42 G=  0 B=212 #2A00D4 &hD4002A 0xD4002A 
58                        R= 42 G= 42 B=  0 #2A2A00 &h002A2A 0x002A2A 
59                        R= 42 G= 42 B= 42 #2A2A2A &h2A2A2A 0x2A2A2A 
60                        R= 42 G= 42 B= 85 #2A2A55 &h552A2A 0x552A2A 
61                        R= 42 G= 42 B=127 #2A2A7F &h7F2A2A 0x7F2A2A 
62                        R= 42 G= 42 B=170 #2A2AAA &hAA2A2A 0xAA2A2A 
63                        R= 42 G= 42 B=212 #2A2AD4 &hD42A2A 0xD42A2A 
64                        R= 42 G= 85 B=  0 #2A5500 &h00552A 0x00552A 
65                        R= 42 G= 85 B= 42 #2A552A &h2A552A 0x2A552A 
66                        R= 42 G= 85 B= 85 #2A5555 &h55552A 0x55552A 
67                        R= 42 G= 85 B=127 #2A557F &h7F552A 0x7F552A 
68                        R= 42 G= 85 B=170 #2A55AA &hAA552A 0xAA552A 
69                        R= 42 G= 85 B=212 #2A55D4 &hD4552A 0xD4552A 
70                        R= 42 G=127 B=  0 #2A7F00 &h007F2A 0x007F2A 
71                        R= 42 G=127 B= 42 #2A7F2A &h2A7F2A 0x2A7F2A 
72                        R= 42 G=127 B= 85 #2A7F55 &h557F2A 0x557F2A 
73                        R= 42 G=127 B=127 #2A7F7F &h7F7F2A 0x7F7F2A 
74                        R= 42 G=127 B=170 #2A7FAA &hAA7F2A 0xAA7F2A 
75                        R= 42 G=127 B=212 #2A7FD4 &hD47F2A 0xD47F2A 
76                        R= 42 G=170 B=  0 #2AAA00 &h00AA2A 0x00AA2A 
77                        R= 42 G=170 B= 42 #2AAA2A &h2AAA2A 0x2AAA2A 
78                        R= 42 G=170 B= 85 #2AAA55 &h55AA2A 0x55AA2A 
79                        R= 42 G=170 B=127 #2AAA7F &h7FAA2A 0x7FAA2A 
80                        R= 42 G=170 B=170 #2AAAAA &hAAAA2A 0xAAAA2A 
81                        R= 42 G=170 B=212 #2AAAD4 &hD4AA2A 0xD4AA2A 
82                        R= 42 G=212 B=  0 #2AD400 &h00D42A 0x00D42A 
83                        R= 42 G=212 B= 42 #2AD42A &h2AD42A 0x2AD42A 
84                        R= 42 G=212 B= 85 #2AD455 &h55D42A 0x55D42A 
85                        R= 42 G=212 B=127 #2AD47F &h7FD42A 0x7FD42A 
86                        R= 42 G=212 B=170 #2AD4AA &hAAD42A 0xAAD42A 
87                        R= 42 G=212 B=212 #2AD4D4 &hD4D42A 0xD4D42A 
88                        R= 85 G=  0 B=  0 #550000 &h000055 0x000055 
89                        R= 85 G=  0 B= 42 #55002A &h2A0055 0x2A0055 
90                        R= 85 G=  0 B= 85 #550055 &h550055 0x550055 
91                        R= 85 G=  0 B=127 #55007F &h7F0055 0x7F0055 
92                        R= 85 G=  0 B=170 #5500AA &hAA0055 0xAA0055 
93                        R= 85 G=  0 B=212 #5500D4 &hD40055 0xD40055 
94                        R= 85 G= 42 B=  0 #552A00 &h002A55 0x002A55 
95                        R= 85 G= 42 B= 42 #552A2A &h2A2A55 0x2A2A55 
96                        R= 85 G= 42 B= 85 #552A55 &h552A55 0x552A55 
97                        R= 85 G= 42 B=127 #552A7F &h7F2A55 0x7F2A55 
98                        R= 85 G= 42 B=170 #552AAA &hAA2A55 0xAA2A55 
99                        R= 85 G= 42 B=212 #552AD4 &hD42A55 0xD42A55 
100                       R= 85 G= 85 B=  0 #555500 &h005555 0x005555 
101                       R= 85 G= 85 B= 42 #55552A &h2A5555 0x2A5555 
102                       R= 85 G= 85 B= 85 #555555 &h555555 0x555555 
103                       R= 85 G= 85 B=127 #55557F &h7F5555 0x7F5555 
104                       R= 85 G= 85 B=170 #5555AA &hAA5555 0xAA5555 
105                       R= 85 G= 85 B=212 #5555D4 &hD45555 0xD45555 
106                       R= 85 G=127 B=  0 #557F00 &h007F55 0x007F55 
107                       R= 85 G=127 B= 42 #557F2A &h2A7F55 0x2A7F55 
108                       R= 85 G=127 B= 85 #557F55 &h557F55 0x557F55 
109                       R= 85 G=127 B=127 #557F7F &h7F7F55 0x7F7F55 
110                       R= 85 G=127 B=170 #557FAA &hAA7F55 0xAA7F55 
111                       R= 85 G=127 B=212 #557FD4 &hD47F55 0xD47F55 
112                       R= 85 G=170 B=  0 #55AA00 &h00AA55 0x00AA55 
113                       R= 85 G=170 B= 42 #55AA2A &h2AAA55 0x2AAA55 
114                       R= 85 G=170 B= 85 #55AA55 &h55AA55 0x55AA55 
115                       R= 85 G=170 B=127 #55AA7F &h7FAA55 0x7FAA55 
116                       R= 85 G=170 B=170 #55AAAA &hAAAA55 0xAAAA55 
117                       R= 85 G=170 B=212 #55AAD4 &hD4AA55 0xD4AA55 
118                       R= 85 G=212 B=  0 #55D400 &h00D455 0x00D455 
119                       R= 85 G=212 B= 42 #55D42A &h2AD455 0x2AD455 
120                       R= 85 G=212 B= 85 #55D455 &h55D455 0x55D455 
121                       R= 85 G=212 B=127 #55D47F &h7FD455 0x7FD455 
122                       R= 85 G=212 B=170 #55D4AA &hAAD455 0xAAD455 
123                       R= 85 G=212 B=212 #55D4D4 &hD4D455 0xD4D455 
124                       R=127 G=  0 B=  0 #7F0000 &h00007F 0x00007F 
125                       R=127 G=  0 B= 42 #7F002A &h2A007F 0x2A007F 
126                       R=127 G=  0 B= 85 #7F0055 &h55007F 0x55007F 
127                       R=127 G=  0 B=127 #7F007F &h7F007F 0x7F007F 
128                       R=127 G=  0 B=170 #7F00AA &hAA007F 0xAA007F 
129                       R=127 G=  0 B=212 #7F00D4 &hD4007F 0xD4007F 
130                       R=127 G= 42 B=  0 #7F2A00 &h002A7F 0x002A7F 
131                       R=127 G= 42 B= 42 #7F2A2A &h2A2A7F 0x2A2A7F 
132                       R=127 G= 42 B= 85 #7F2A55 &h552A7F 0x552A7F 
133                       R=127 G= 42 B=127 #7F2A7F &h7F2A7F 0x7F2A7F 
134                       R=127 G= 42 B=170 #7F2AAA &hAA2A7F 0xAA2A7F 
135                       R=127 G= 42 B=212 #7F2AD4 &hD42A7F 0xD42A7F 
136                       R=127 G= 85 B=  0 #7F5500 &h00557F 0x00557F 
137                       R=127 G= 85 B= 42 #7F552A &h2A557F 0x2A557F 
138                       R=127 G= 85 B= 85 #7F5555 &h55557F 0x55557F 
139                       R=127 G= 85 B=127 #7F557F &h7F557F 0x7F557F 
140                       R=127 G= 85 B=170 #7F55AA &hAA557F 0xAA557F 
141                       R=127 G= 85 B=212 #7F55D4 &hD4557F 0xD4557F 
142                       R=127 G=127 B=  0 #7F7F00 &h007F7F 0x007F7F 
143                       R=127 G=127 B= 42 #7F7F2A &h2A7F7F 0x2A7F7F 
144                       R=127 G=127 B= 85 #7F7F55 &h557F7F 0x557F7F 
145                       R=127 G=127 B=127 #7F7F7F &h7F7F7F 0x7F7F7F 
146                       R=127 G=127 B=170 #7F7FAA &hAA7F7F 0xAA7F7F 
147                       R=127 G=127 B=212 #7F7FD4 &hD47F7F 0xD47F7F 
148                       R=127 G=170 B=  0 #7FAA00 &h00AA7F 0x00AA7F 
149                       R=127 G=170 B= 42 #7FAA2A &h2AAA7F 0x2AAA7F 
150                       R=127 G=170 B= 85 #7FAA55 &h55AA7F 0x55AA7F 
151                       R=127 G=170 B=127 #7FAA7F &h7FAA7F 0x7FAA7F 
152                       R=127 G=170 B=170 #7FAAAA &hAAAA7F 0xAAAA7F 
153                       R=127 G=170 B=212 #7FAAD4 &hD4AA7F 0xD4AA7F 
154                       R=127 G=212 B=  0 #7FD400 &h00D47F 0x00D47F 
155                       R=127 G=212 B= 42 #7FD42A &h2AD47F 0x2AD47F 
156                       R=127 G=212 B= 85 #7FD455 &h55D47F 0x55D47F 
157                       R=127 G=212 B=127 #7FD47F &h7FD47F 0x7FD47F 
158                       R=127 G=212 B=170 #7FD4AA &hAAD47F 0xAAD47F 
159                       R=127 G=212 B=212 #7FD4D4 &hD4D47F 0xD4D47F 
160                       R=170 G=  0 B=  0 #AA0000 &h0000AA 0x0000AA 
161                       R=170 G=  0 B= 42 #AA002A &h2A00AA 0x2A00AA 
162                       R=170 G=  0 B= 85 #AA0055 &h5500AA 0x5500AA 
163                       R=170 G=  0 B=127 #AA007F &h7F00AA 0x7F00AA 
164                       R=170 G=  0 B=170 #AA00AA &hAA00AA 0xAA00AA 
165                       R=170 G=  0 B=212 #AA00D4 &hD400AA 0xD400AA 
166                       R=170 G= 42 B=  0 #AA2A00 &h002AAA 0x002AAA 
167                       R=170 G= 42 B= 42 #AA2A2A &h2A2AAA 0x2A2AAA 
168                       R=170 G= 42 B= 85 #AA2A55 &h552AAA 0x552AAA 
169                       R=170 G= 42 B=127 #AA2A7F &h7F2AAA 0x7F2AAA 
170                       R=170 G= 42 B=170 #AA2AAA &hAA2AAA 0xAA2AAA 
171                       R=170 G= 42 B=212 #AA2AD4 &hD42AAA 0xD42AAA 
172                       R=170 G= 85 B=  0 #AA5500 &h0055AA 0x0055AA 
173                       R=170 G= 85 B= 42 #AA552A &h2A55AA 0x2A55AA 
174                       R=170 G= 85 B= 85 #AA5555 &h5555AA 0x5555AA 
175                       R=170 G= 85 B=127 #AA557F &h7F55AA 0x7F55AA 
176                       R=170 G= 85 B=170 #AA55AA &hAA55AA 0xAA55AA 
177                       R=170 G= 85 B=212 #AA55D4 &hD455AA 0xD455AA 
178                       R=170 G=127 B=  0 #AA7F00 &h007FAA 0x007FAA 
179                       R=170 G=127 B= 42 #AA7F2A &h2A7FAA 0x2A7FAA 
180                       R=170 G=127 B= 85 #AA7F55 &h557FAA 0x557FAA 
181                       R=170 G=127 B=127 #AA7F7F &h7F7FAA 0x7F7FAA 
182                       R=170 G=127 B=170 #AA7FAA &hAA7FAA 0xAA7FAA 
183                       R=170 G=127 B=212 #AA7FD4 &hD47FAA 0xD47FAA 
184                       R=170 G=170 B=  0 #AAAA00 &h00AAAA 0x00AAAA 
185                       R=170 G=170 B= 42 #AAAA2A &h2AAAAA 0x2AAAAA 
186                       R=170 G=170 B= 85 #AAAA55 &h55AAAA 0x55AAAA 
187                       R=170 G=170 B=127 #AAAA7F &h7FAAAA 0x7FAAAA 
188                       R=170 G=170 B=170 #AAAAAA &hAAAAAA 0xAAAAAA 
189                       R=170 G=170 B=212 #AAAAD4 &hD4AAAA 0xD4AAAA 
190                       R=170 G=212 B=  0 #AAD400 &h00D4AA 0x00D4AA 
191                       R=170 G=212 B= 42 #AAD42A &h2AD4AA 0x2AD4AA 
192                       R=170 G=212 B= 85 #AAD455 &h55D4AA 0x55D4AA 
193                       R=170 G=212 B=127 #AAD47F &h7FD4AA 0x7FD4AA 
194                       R=170 G=212 B=170 #AAD4AA &hAAD4AA 0xAAD4AA 
195                       R=170 G=212 B=212 #AAD4D4 &hD4D4AA 0xD4D4AA 
196                       R=212 G=  0 B=  0 #D40000 &h0000D4 0x0000D4 
197                       R=212 G=  0 B= 42 #D4002A &h2A00D4 0x2A00D4 
198                       R=212 G=  0 B= 85 #D40055 &h5500D4 0x5500D4 
199                       R=212 G=  0 B=127 #D4007F &h7F00D4 0x7F00D4 
200                       R=212 G=  0 B=170 #D400AA &hAA00D4 0xAA00D4 
201                       R=212 G=  0 B=212 #D400D4 &hD400D4 0xD400D4 
202                       R=212 G= 42 B=  0 #D42A00 &h002AD4 0x002AD4 
203                       R=212 G= 42 B= 42 #D42A2A &h2A2AD4 0x2A2AD4 
204                       R=212 G= 42 B= 85 #D42A55 &h552AD4 0x552AD4 
205                       R=212 G= 42 B=127 #D42A7F &h7F2AD4 0x7F2AD4 
206                       R=212 G= 42 B=170 #D42AAA &hAA2AD4 0xAA2AD4 
207                       R=212 G= 42 B=212 #D42AD4 &hD42AD4 0xD42AD4 
208                       R=212 G= 85 B=  0 #D45500 &h0055D4 0x0055D4 
209                       R=212 G= 85 B= 42 #D4552A &h2A55D4 0x2A55D4 
210                       R=212 G= 85 B= 85 #D45555 &h5555D4 0x5555D4 
211                       R=212 G= 85 B=127 #D4557F &h7F55D4 0x7F55D4 
212                       R=212 G= 85 B=170 #D455AA &hAA55D4 0xAA55D4 
213                       R=212 G= 85 B=212 #D455D4 &hD455D4 0xD455D4 
214                       R=212 G=127 B=  0 #D47F00 &h007FD4 0x007FD4 
215                       R=212 G=127 B= 42 #D47F2A &h2A7FD4 0x2A7FD4 
216                       R=212 G=127 B= 85 #D47F55 &h557FD4 0x557FD4 
217                       R=212 G=127 B=127 #D47F7F &h7F7FD4 0x7F7FD4 
218                       R=212 G=127 B=170 #D47FAA &hAA7FD4 0xAA7FD4 
219                       R=212 G=127 B=212 #D47FD4 &hD47FD4 0xD47FD4 
220                       R=212 G=170 B=  0 #D4AA00 &h00AAD4 0x00AAD4 
221                       R=212 G=170 B= 42 #D4AA2A &h2AAAD4 0x2AAAD4 
222                       R=212 G=170 B= 85 #D4AA55 &h55AAD4 0x55AAD4 
223                       R=212 G=170 B=127 #D4AA7F &h7FAAD4 0x7FAAD4 
224                       R=212 G=170 B=170 #D4AAAA &hAAAAD4 0xAAAAD4 
225                       R=212 G=170 B=212 #D4AAD4 &hD4AAD4 0xD4AAD4 
226                       R=212 G=212 B=  0 #D4D400 &h00D4D4 0x00D4D4 
227                       R=212 G=212 B= 42 #D4D42A &h2AD4D4 0x2AD4D4 
228                       R=212 G=212 B= 85 #D4D455 &h55D4D4 0x55D4D4 
229                       R=212 G=212 B=127 #D4D47F &h7FD4D4 0x7FD4D4 
230                       R=212 G=212 B=170 #D4D4AA &hAAD4D4 0xAAD4D4 
231                       R=212 G=212 B=212 #D4D4D4 &hD4D4D4 0xD4D4D4 


You can see that the brightest value here (for item 231) is #D4D4D4 compared to the earlier approach which gave a brighest value of #FFFFFF.
Amended on Sat 07 Apr 2007 03:01 AM by Nick Gammon
Australia Forum Administrator #30
A bit more research indicates maybe this is the correct gap sequence:


// the 6 value iterations in the xterm color cube
static const unsigned char valuerange[] = { 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF };


This is different from my original sequence (DF becomes D7), but at least the gaps are more consistent now:


95 + 40 + 40 + 40 + 40 = 255


This gives the following codes:


16 (black)                R=  0 G=  0 B=  0 #000000 &h000000 0x000000 
17                        R=  0 G=  0 B= 95 #00005F &h5F0000 0x5F0000 
18                        R=  0 G=  0 B=135 #000087 &h870000 0x870000 
19                        R=  0 G=  0 B=175 #0000AF &hAF0000 0xAF0000 
20                        R=  0 G=  0 B=215 #0000D7 &hD70000 0xD70000 
21 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 
22                        R=  0 G= 95 B=  0 #005F00 &h005F00 0x005F00 
23                        R=  0 G= 95 B= 95 #005F5F &h5F5F00 0x5F5F00 
24                        R=  0 G= 95 B=135 #005F87 &h875F00 0x875F00 
25                        R=  0 G= 95 B=175 #005FAF &hAF5F00 0xAF5F00 
26                        R=  0 G= 95 B=215 #005FD7 &hD75F00 0xD75F00 
27                        R=  0 G= 95 B=255 #005FFF &hFF5F00 0xFF5F00 
28                        R=  0 G=135 B=  0 #008700 &h008700 0x008700 
29                        R=  0 G=135 B= 95 #00875F &h5F8700 0x5F8700 
30                        R=  0 G=135 B=135 #008787 &h878700 0x878700 
31                        R=  0 G=135 B=175 #0087AF &hAF8700 0xAF8700 
32                        R=  0 G=135 B=215 #0087D7 &hD78700 0xD78700 
33                        R=  0 G=135 B=255 #0087FF &hFF8700 0xFF8700 
34                        R=  0 G=175 B=  0 #00AF00 &h00AF00 0x00AF00 
35                        R=  0 G=175 B= 95 #00AF5F &h5FAF00 0x5FAF00 
36                        R=  0 G=175 B=135 #00AF87 &h87AF00 0x87AF00 
37                        R=  0 G=175 B=175 #00AFAF &hAFAF00 0xAFAF00 
38                        R=  0 G=175 B=215 #00AFD7 &hD7AF00 0xD7AF00 
39                        R=  0 G=175 B=255 #00AFFF &hFFAF00 0xFFAF00 
40                        R=  0 G=215 B=  0 #00D700 &h00D700 0x00D700 
41                        R=  0 G=215 B= 95 #00D75F &h5FD700 0x5FD700 
42                        R=  0 G=215 B=135 #00D787 &h87D700 0x87D700 
43                        R=  0 G=215 B=175 #00D7AF &hAFD700 0xAFD700 
44                        R=  0 G=215 B=215 #00D7D7 &hD7D700 0xD7D700 
45                        R=  0 G=215 B=255 #00D7FF &hFFD700 0xFFD700 
46 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 
47                        R=  0 G=255 B= 95 #00FF5F &h5FFF00 0x5FFF00 
48                        R=  0 G=255 B=135 #00FF87 &h87FF00 0x87FF00 
49                        R=  0 G=255 B=175 #00FFAF &hAFFF00 0xAFFF00 
50                        R=  0 G=255 B=215 #00FFD7 &hD7FF00 0xD7FF00 
51 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 
52                        R= 95 G=  0 B=  0 #5F0000 &h00005F 0x00005F 
53                        R= 95 G=  0 B= 95 #5F005F &h5F005F 0x5F005F 
54                        R= 95 G=  0 B=135 #5F0087 &h87005F 0x87005F 
55                        R= 95 G=  0 B=175 #5F00AF &hAF005F 0xAF005F 
56                        R= 95 G=  0 B=215 #5F00D7 &hD7005F 0xD7005F 
57                        R= 95 G=  0 B=255 #5F00FF &hFF005F 0xFF005F 
58                        R= 95 G= 95 B=  0 #5F5F00 &h005F5F 0x005F5F 
59                        R= 95 G= 95 B= 95 #5F5F5F &h5F5F5F 0x5F5F5F 
60                        R= 95 G= 95 B=135 #5F5F87 &h875F5F 0x875F5F 
61                        R= 95 G= 95 B=175 #5F5FAF &hAF5F5F 0xAF5F5F 
62                        R= 95 G= 95 B=215 #5F5FD7 &hD75F5F 0xD75F5F 
63                        R= 95 G= 95 B=255 #5F5FFF &hFF5F5F 0xFF5F5F 
64                        R= 95 G=135 B=  0 #5F8700 &h00875F 0x00875F 
65                        R= 95 G=135 B= 95 #5F875F &h5F875F 0x5F875F 
66                        R= 95 G=135 B=135 #5F8787 &h87875F 0x87875F 
67                        R= 95 G=135 B=175 #5F87AF &hAF875F 0xAF875F 
68                        R= 95 G=135 B=215 #5F87D7 &hD7875F 0xD7875F 
69                        R= 95 G=135 B=255 #5F87FF &hFF875F 0xFF875F 
70                        R= 95 G=175 B=  0 #5FAF00 &h00AF5F 0x00AF5F 
71                        R= 95 G=175 B= 95 #5FAF5F &h5FAF5F 0x5FAF5F 
72                        R= 95 G=175 B=135 #5FAF87 &h87AF5F 0x87AF5F 
73                        R= 95 G=175 B=175 #5FAFAF &hAFAF5F 0xAFAF5F 
74                        R= 95 G=175 B=215 #5FAFD7 &hD7AF5F 0xD7AF5F 
75                        R= 95 G=175 B=255 #5FAFFF &hFFAF5F 0xFFAF5F 
76                        R= 95 G=215 B=  0 #5FD700 &h00D75F 0x00D75F 
77                        R= 95 G=215 B= 95 #5FD75F &h5FD75F 0x5FD75F 
78                        R= 95 G=215 B=135 #5FD787 &h87D75F 0x87D75F 
79                        R= 95 G=215 B=175 #5FD7AF &hAFD75F 0xAFD75F 
80                        R= 95 G=215 B=215 #5FD7D7 &hD7D75F 0xD7D75F 
81                        R= 95 G=215 B=255 #5FD7FF &hFFD75F 0xFFD75F 
82                        R= 95 G=255 B=  0 #5FFF00 &h00FF5F 0x00FF5F 
83                        R= 95 G=255 B= 95 #5FFF5F &h5FFF5F 0x5FFF5F 
84                        R= 95 G=255 B=135 #5FFF87 &h87FF5F 0x87FF5F 
85                        R= 95 G=255 B=175 #5FFFAF &hAFFF5F 0xAFFF5F 
86                        R= 95 G=255 B=215 #5FFFD7 &hD7FF5F 0xD7FF5F 
87                        R= 95 G=255 B=255 #5FFFFF &hFFFF5F 0xFFFF5F 
88                        R=135 G=  0 B=  0 #870000 &h000087 0x000087 
89                        R=135 G=  0 B= 95 #87005F &h5F0087 0x5F0087 
90                        R=135 G=  0 B=135 #870087 &h870087 0x870087 
91                        R=135 G=  0 B=175 #8700AF &hAF0087 0xAF0087 
92                        R=135 G=  0 B=215 #8700D7 &hD70087 0xD70087 
93                        R=135 G=  0 B=255 #8700FF &hFF0087 0xFF0087 
94                        R=135 G= 95 B=  0 #875F00 &h005F87 0x005F87 
95                        R=135 G= 95 B= 95 #875F5F &h5F5F87 0x5F5F87 
96                        R=135 G= 95 B=135 #875F87 &h875F87 0x875F87 
97                        R=135 G= 95 B=175 #875FAF &hAF5F87 0xAF5F87 
98                        R=135 G= 95 B=215 #875FD7 &hD75F87 0xD75F87 
99                        R=135 G= 95 B=255 #875FFF &hFF5F87 0xFF5F87 
100                       R=135 G=135 B=  0 #878700 &h008787 0x008787 
101                       R=135 G=135 B= 95 #87875F &h5F8787 0x5F8787 
102                       R=135 G=135 B=135 #878787 &h878787 0x878787 
103                       R=135 G=135 B=175 #8787AF &hAF8787 0xAF8787 
104                       R=135 G=135 B=215 #8787D7 &hD78787 0xD78787 
105                       R=135 G=135 B=255 #8787FF &hFF8787 0xFF8787 
106                       R=135 G=175 B=  0 #87AF00 &h00AF87 0x00AF87 
107                       R=135 G=175 B= 95 #87AF5F &h5FAF87 0x5FAF87 
108                       R=135 G=175 B=135 #87AF87 &h87AF87 0x87AF87 
109                       R=135 G=175 B=175 #87AFAF &hAFAF87 0xAFAF87 
110                       R=135 G=175 B=215 #87AFD7 &hD7AF87 0xD7AF87 
111                       R=135 G=175 B=255 #87AFFF &hFFAF87 0xFFAF87 
112                       R=135 G=215 B=  0 #87D700 &h00D787 0x00D787 
113                       R=135 G=215 B= 95 #87D75F &h5FD787 0x5FD787 
114                       R=135 G=215 B=135 #87D787 &h87D787 0x87D787 
115                       R=135 G=215 B=175 #87D7AF &hAFD787 0xAFD787 
116                       R=135 G=215 B=215 #87D7D7 &hD7D787 0xD7D787 
117                       R=135 G=215 B=255 #87D7FF &hFFD787 0xFFD787 
118                       R=135 G=255 B=  0 #87FF00 &h00FF87 0x00FF87 
119                       R=135 G=255 B= 95 #87FF5F &h5FFF87 0x5FFF87 
120                       R=135 G=255 B=135 #87FF87 &h87FF87 0x87FF87 
121                       R=135 G=255 B=175 #87FFAF &hAFFF87 0xAFFF87 
122                       R=135 G=255 B=215 #87FFD7 &hD7FF87 0xD7FF87 
123                       R=135 G=255 B=255 #87FFFF &hFFFF87 0xFFFF87 
124                       R=175 G=  0 B=  0 #AF0000 &h0000AF 0x0000AF 
125                       R=175 G=  0 B= 95 #AF005F &h5F00AF 0x5F00AF 
126                       R=175 G=  0 B=135 #AF0087 &h8700AF 0x8700AF 
127                       R=175 G=  0 B=175 #AF00AF &hAF00AF 0xAF00AF 
128                       R=175 G=  0 B=215 #AF00D7 &hD700AF 0xD700AF 
129                       R=175 G=  0 B=255 #AF00FF &hFF00AF 0xFF00AF 
130                       R=175 G= 95 B=  0 #AF5F00 &h005FAF 0x005FAF 
131                       R=175 G= 95 B= 95 #AF5F5F &h5F5FAF 0x5F5FAF 
132                       R=175 G= 95 B=135 #AF5F87 &h875FAF 0x875FAF 
133                       R=175 G= 95 B=175 #AF5FAF &hAF5FAF 0xAF5FAF 
134                       R=175 G= 95 B=215 #AF5FD7 &hD75FAF 0xD75FAF 
135                       R=175 G= 95 B=255 #AF5FFF &hFF5FAF 0xFF5FAF 
136                       R=175 G=135 B=  0 #AF8700 &h0087AF 0x0087AF 
137                       R=175 G=135 B= 95 #AF875F &h5F87AF 0x5F87AF 
138                       R=175 G=135 B=135 #AF8787 &h8787AF 0x8787AF 
139                       R=175 G=135 B=175 #AF87AF &hAF87AF 0xAF87AF 
140                       R=175 G=135 B=215 #AF87D7 &hD787AF 0xD787AF 
141                       R=175 G=135 B=255 #AF87FF &hFF87AF 0xFF87AF 
142                       R=175 G=175 B=  0 #AFAF00 &h00AFAF 0x00AFAF 
143                       R=175 G=175 B= 95 #AFAF5F &h5FAFAF 0x5FAFAF 
144                       R=175 G=175 B=135 #AFAF87 &h87AFAF 0x87AFAF 
145                       R=175 G=175 B=175 #AFAFAF &hAFAFAF 0xAFAFAF 
146                       R=175 G=175 B=215 #AFAFD7 &hD7AFAF 0xD7AFAF 
147                       R=175 G=175 B=255 #AFAFFF &hFFAFAF 0xFFAFAF 
148                       R=175 G=215 B=  0 #AFD700 &h00D7AF 0x00D7AF 
149                       R=175 G=215 B= 95 #AFD75F &h5FD7AF 0x5FD7AF 
150                       R=175 G=215 B=135 #AFD787 &h87D7AF 0x87D7AF 
151                       R=175 G=215 B=175 #AFD7AF &hAFD7AF 0xAFD7AF 
152                       R=175 G=215 B=215 #AFD7D7 &hD7D7AF 0xD7D7AF 
153                       R=175 G=215 B=255 #AFD7FF &hFFD7AF 0xFFD7AF 
154                       R=175 G=255 B=  0 #AFFF00 &h00FFAF 0x00FFAF 
155                       R=175 G=255 B= 95 #AFFF5F &h5FFFAF 0x5FFFAF 
156                       R=175 G=255 B=135 #AFFF87 &h87FFAF 0x87FFAF 
157                       R=175 G=255 B=175 #AFFFAF &hAFFFAF 0xAFFFAF 
158                       R=175 G=255 B=215 #AFFFD7 &hD7FFAF 0xD7FFAF 
159                       R=175 G=255 B=255 #AFFFFF &hFFFFAF 0xFFFFAF 
160                       R=215 G=  0 B=  0 #D70000 &h0000D7 0x0000D7 
161                       R=215 G=  0 B= 95 #D7005F &h5F00D7 0x5F00D7 
162                       R=215 G=  0 B=135 #D70087 &h8700D7 0x8700D7 
163                       R=215 G=  0 B=175 #D700AF &hAF00D7 0xAF00D7 
164                       R=215 G=  0 B=215 #D700D7 &hD700D7 0xD700D7 
165                       R=215 G=  0 B=255 #D700FF &hFF00D7 0xFF00D7 
166                       R=215 G= 95 B=  0 #D75F00 &h005FD7 0x005FD7 
167                       R=215 G= 95 B= 95 #D75F5F &h5F5FD7 0x5F5FD7 
168                       R=215 G= 95 B=135 #D75F87 &h875FD7 0x875FD7 
169                       R=215 G= 95 B=175 #D75FAF &hAF5FD7 0xAF5FD7 
170                       R=215 G= 95 B=215 #D75FD7 &hD75FD7 0xD75FD7 
171                       R=215 G= 95 B=255 #D75FFF &hFF5FD7 0xFF5FD7 
172                       R=215 G=135 B=  0 #D78700 &h0087D7 0x0087D7 
173                       R=215 G=135 B= 95 #D7875F &h5F87D7 0x5F87D7 
174                       R=215 G=135 B=135 #D78787 &h8787D7 0x8787D7 
175                       R=215 G=135 B=175 #D787AF &hAF87D7 0xAF87D7 
176                       R=215 G=135 B=215 #D787D7 &hD787D7 0xD787D7 
177                       R=215 G=135 B=255 #D787FF &hFF87D7 0xFF87D7 
178                       R=215 G=175 B=  0 #D7AF00 &h00AFD7 0x00AFD7 
179                       R=215 G=175 B= 95 #D7AF5F &h5FAFD7 0x5FAFD7 
180                       R=215 G=175 B=135 #D7AF87 &h87AFD7 0x87AFD7 
181                       R=215 G=175 B=175 #D7AFAF &hAFAFD7 0xAFAFD7 
182                       R=215 G=175 B=215 #D7AFD7 &hD7AFD7 0xD7AFD7 
183                       R=215 G=175 B=255 #D7AFFF &hFFAFD7 0xFFAFD7 
184                       R=215 G=215 B=  0 #D7D700 &h00D7D7 0x00D7D7 
185                       R=215 G=215 B= 95 #D7D75F &h5FD7D7 0x5FD7D7 
186                       R=215 G=215 B=135 #D7D787 &h87D7D7 0x87D7D7 
187                       R=215 G=215 B=175 #D7D7AF &hAFD7D7 0xAFD7D7 
188                       R=215 G=215 B=215 #D7D7D7 &hD7D7D7 0xD7D7D7 
189                       R=215 G=215 B=255 #D7D7FF &hFFD7D7 0xFFD7D7 
190                       R=215 G=255 B=  0 #D7FF00 &h00FFD7 0x00FFD7 
191                       R=215 G=255 B= 95 #D7FF5F &h5FFFD7 0x5FFFD7 
192                       R=215 G=255 B=135 #D7FF87 &h87FFD7 0x87FFD7 
193                       R=215 G=255 B=175 #D7FFAF &hAFFFD7 0xAFFFD7 
194                       R=215 G=255 B=215 #D7FFD7 &hD7FFD7 0xD7FFD7 
195                       R=215 G=255 B=255 #D7FFFF &hFFFFD7 0xFFFFD7 
196 (red)                 R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 
197                       R=255 G=  0 B= 95 #FF005F &h5F00FF 0x5F00FF 
198                       R=255 G=  0 B=135 #FF0087 &h8700FF 0x8700FF 
199                       R=255 G=  0 B=175 #FF00AF &hAF00FF 0xAF00FF 
200                       R=255 G=  0 B=215 #FF00D7 &hD700FF 0xD700FF 
201 (magenta, fuchsia)    R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 
202                       R=255 G= 95 B=  0 #FF5F00 &h005FFF 0x005FFF 
203                       R=255 G= 95 B= 95 #FF5F5F &h5F5FFF 0x5F5FFF 
204                       R=255 G= 95 B=135 #FF5F87 &h875FFF 0x875FFF 
205                       R=255 G= 95 B=175 #FF5FAF &hAF5FFF 0xAF5FFF 
206                       R=255 G= 95 B=215 #FF5FD7 &hD75FFF 0xD75FFF 
207                       R=255 G= 95 B=255 #FF5FFF &hFF5FFF 0xFF5FFF 
208                       R=255 G=135 B=  0 #FF8700 &h0087FF 0x0087FF 
209                       R=255 G=135 B= 95 #FF875F &h5F87FF 0x5F87FF 
210                       R=255 G=135 B=135 #FF8787 &h8787FF 0x8787FF 
211                       R=255 G=135 B=175 #FF87AF &hAF87FF 0xAF87FF 
212                       R=255 G=135 B=215 #FF87D7 &hD787FF 0xD787FF 
213                       R=255 G=135 B=255 #FF87FF &hFF87FF 0xFF87FF 
214                       R=255 G=175 B=  0 #FFAF00 &h00AFFF 0x00AFFF 
215                       R=255 G=175 B= 95 #FFAF5F &h5FAFFF 0x5FAFFF 
216                       R=255 G=175 B=135 #FFAF87 &h87AFFF 0x87AFFF 
217                       R=255 G=175 B=175 #FFAFAF &hAFAFFF 0xAFAFFF 
218                       R=255 G=175 B=215 #FFAFD7 &hD7AFFF 0xD7AFFF 
219                       R=255 G=175 B=255 #FFAFFF &hFFAFFF 0xFFAFFF 
220 (gold)                R=255 G=215 B=  0 #FFD700 &h00D7FF 0x00D7FF 
221                       R=255 G=215 B= 95 #FFD75F &h5FD7FF 0x5FD7FF 
222                       R=255 G=215 B=135 #FFD787 &h87D7FF 0x87D7FF 
223                       R=255 G=215 B=175 #FFD7AF &hAFD7FF 0xAFD7FF 
224                       R=255 G=215 B=215 #FFD7D7 &hD7D7FF 0xD7D7FF 
225                       R=255 G=215 B=255 #FFD7FF &hFFD7FF 0xFFD7FF 
226 (yellow)              R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 
227                       R=255 G=255 B= 95 #FFFF5F &h5FFFFF 0x5FFFFF 
228                       R=255 G=255 B=135 #FFFF87 &h87FFFF 0x87FFFF 
229                       R=255 G=255 B=175 #FFFFAF &hAFFFFF 0xAFFFFF 
230                       R=255 G=255 B=215 #FFFFD7 &hD7FFFF 0xD7FFFF 
231 (white)               R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 

Australia Forum Administrator #31
Quote:

(quoting myself)

Another site I came across seems to suggest that the colours *should* be evenly spaced in the colour cube, by an amount of 42.5 (ie. 256 / 6) rather than the spacing given on the page above.


Of course, this is nonsense because it should really be 255/5 (51) rather than 42.5. That way the range is 0x00 to 0xFF in even increments.

That is, this algorithm:


  for (red = 0; red < 6; red++)
      for (green = 0; green < 6; green++)
        for (blue = 0; blue < 6; blue++)
           xterm_256_colours [16 + (red * 36) + (blue * 6) + green] =
              RGB (red * 51, blue * 51, green * 51);


That gives this result:


16 (black)                R=  0 G=  0 B=  0 #000000 &h000000 0x000000 
17                        R=  0 G=  0 B= 51 #000033 &h330000 0x330000 
18                        R=  0 G=  0 B=102 #000066 &h660000 0x660000 
19                        R=  0 G=  0 B=153 #000099 &h990000 0x990000 
20                        R=  0 G=  0 B=204 #0000CC &hCC0000 0xCC0000 
21 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 
22                        R=  0 G= 51 B=  0 #003300 &h003300 0x003300 
23                        R=  0 G= 51 B= 51 #003333 &h333300 0x333300 
24                        R=  0 G= 51 B=102 #003366 &h663300 0x663300 
25                        R=  0 G= 51 B=153 #003399 &h993300 0x993300 
26                        R=  0 G= 51 B=204 #0033CC &hCC3300 0xCC3300 
27                        R=  0 G= 51 B=255 #0033FF &hFF3300 0xFF3300 
28                        R=  0 G=102 B=  0 #006600 &h006600 0x006600 
29                        R=  0 G=102 B= 51 #006633 &h336600 0x336600 
30                        R=  0 G=102 B=102 #006666 &h666600 0x666600 
31                        R=  0 G=102 B=153 #006699 &h996600 0x996600 
32                        R=  0 G=102 B=204 #0066CC &hCC6600 0xCC6600 
33                        R=  0 G=102 B=255 #0066FF &hFF6600 0xFF6600 
34                        R=  0 G=153 B=  0 #009900 &h009900 0x009900 
35                        R=  0 G=153 B= 51 #009933 &h339900 0x339900 
36                        R=  0 G=153 B=102 #009966 &h669900 0x669900 
37                        R=  0 G=153 B=153 #009999 &h999900 0x999900 
38                        R=  0 G=153 B=204 #0099CC &hCC9900 0xCC9900 
39                        R=  0 G=153 B=255 #0099FF &hFF9900 0xFF9900 
40                        R=  0 G=204 B=  0 #00CC00 &h00CC00 0x00CC00 
41                        R=  0 G=204 B= 51 #00CC33 &h33CC00 0x33CC00 
42                        R=  0 G=204 B=102 #00CC66 &h66CC00 0x66CC00 
43                        R=  0 G=204 B=153 #00CC99 &h99CC00 0x99CC00 
44                        R=  0 G=204 B=204 #00CCCC &hCCCC00 0xCCCC00 
45                        R=  0 G=204 B=255 #00CCFF &hFFCC00 0xFFCC00 
46 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 
47                        R=  0 G=255 B= 51 #00FF33 &h33FF00 0x33FF00 
48                        R=  0 G=255 B=102 #00FF66 &h66FF00 0x66FF00 
49                        R=  0 G=255 B=153 #00FF99 &h99FF00 0x99FF00 
50                        R=  0 G=255 B=204 #00FFCC &hCCFF00 0xCCFF00 
51 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 
52                        R= 51 G=  0 B=  0 #330000 &h000033 0x000033 
53                        R= 51 G=  0 B= 51 #330033 &h330033 0x330033 
54                        R= 51 G=  0 B=102 #330066 &h660033 0x660033 
55                        R= 51 G=  0 B=153 #330099 &h990033 0x990033 
56                        R= 51 G=  0 B=204 #3300CC &hCC0033 0xCC0033 
57                        R= 51 G=  0 B=255 #3300FF &hFF0033 0xFF0033 
58                        R= 51 G= 51 B=  0 #333300 &h003333 0x003333 
59                        R= 51 G= 51 B= 51 #333333 &h333333 0x333333 
60                        R= 51 G= 51 B=102 #333366 &h663333 0x663333 
61                        R= 51 G= 51 B=153 #333399 &h993333 0x993333 
62                        R= 51 G= 51 B=204 #3333CC &hCC3333 0xCC3333 
63                        R= 51 G= 51 B=255 #3333FF &hFF3333 0xFF3333 
64                        R= 51 G=102 B=  0 #336600 &h006633 0x006633 
65                        R= 51 G=102 B= 51 #336633 &h336633 0x336633 
66                        R= 51 G=102 B=102 #336666 &h666633 0x666633 
67                        R= 51 G=102 B=153 #336699 &h996633 0x996633 
68                        R= 51 G=102 B=204 #3366CC &hCC6633 0xCC6633 
69                        R= 51 G=102 B=255 #3366FF &hFF6633 0xFF6633 
70                        R= 51 G=153 B=  0 #339900 &h009933 0x009933 
71                        R= 51 G=153 B= 51 #339933 &h339933 0x339933 
72                        R= 51 G=153 B=102 #339966 &h669933 0x669933 
73                        R= 51 G=153 B=153 #339999 &h999933 0x999933 
74                        R= 51 G=153 B=204 #3399CC &hCC9933 0xCC9933 
75                        R= 51 G=153 B=255 #3399FF &hFF9933 0xFF9933 
76                        R= 51 G=204 B=  0 #33CC00 &h00CC33 0x00CC33 
77                        R= 51 G=204 B= 51 #33CC33 &h33CC33 0x33CC33 
78                        R= 51 G=204 B=102 #33CC66 &h66CC33 0x66CC33 
79                        R= 51 G=204 B=153 #33CC99 &h99CC33 0x99CC33 
80                        R= 51 G=204 B=204 #33CCCC &hCCCC33 0xCCCC33 
81                        R= 51 G=204 B=255 #33CCFF &hFFCC33 0xFFCC33 
82                        R= 51 G=255 B=  0 #33FF00 &h00FF33 0x00FF33 
83                        R= 51 G=255 B= 51 #33FF33 &h33FF33 0x33FF33 
84                        R= 51 G=255 B=102 #33FF66 &h66FF33 0x66FF33 
85                        R= 51 G=255 B=153 #33FF99 &h99FF33 0x99FF33 
86                        R= 51 G=255 B=204 #33FFCC &hCCFF33 0xCCFF33 
87                        R= 51 G=255 B=255 #33FFFF &hFFFF33 0xFFFF33 
88                        R=102 G=  0 B=  0 #660000 &h000066 0x000066 
89                        R=102 G=  0 B= 51 #660033 &h330066 0x330066 
90                        R=102 G=  0 B=102 #660066 &h660066 0x660066 
91                        R=102 G=  0 B=153 #660099 &h990066 0x990066 
92                        R=102 G=  0 B=204 #6600CC &hCC0066 0xCC0066 
93                        R=102 G=  0 B=255 #6600FF &hFF0066 0xFF0066 
94                        R=102 G= 51 B=  0 #663300 &h003366 0x003366 
95                        R=102 G= 51 B= 51 #663333 &h333366 0x333366 
96                        R=102 G= 51 B=102 #663366 &h663366 0x663366 
97                        R=102 G= 51 B=153 #663399 &h993366 0x993366 
98                        R=102 G= 51 B=204 #6633CC &hCC3366 0xCC3366 
99                        R=102 G= 51 B=255 #6633FF &hFF3366 0xFF3366 
100                       R=102 G=102 B=  0 #666600 &h006666 0x006666 
101                       R=102 G=102 B= 51 #666633 &h336666 0x336666 
102                       R=102 G=102 B=102 #666666 &h666666 0x666666 
103                       R=102 G=102 B=153 #666699 &h996666 0x996666 
104                       R=102 G=102 B=204 #6666CC &hCC6666 0xCC6666 
105                       R=102 G=102 B=255 #6666FF &hFF6666 0xFF6666 
106                       R=102 G=153 B=  0 #669900 &h009966 0x009966 
107                       R=102 G=153 B= 51 #669933 &h339966 0x339966 
108                       R=102 G=153 B=102 #669966 &h669966 0x669966 
109                       R=102 G=153 B=153 #669999 &h999966 0x999966 
110                       R=102 G=153 B=204 #6699CC &hCC9966 0xCC9966 
111                       R=102 G=153 B=255 #6699FF &hFF9966 0xFF9966 
112                       R=102 G=204 B=  0 #66CC00 &h00CC66 0x00CC66 
113                       R=102 G=204 B= 51 #66CC33 &h33CC66 0x33CC66 
114                       R=102 G=204 B=102 #66CC66 &h66CC66 0x66CC66 
115                       R=102 G=204 B=153 #66CC99 &h99CC66 0x99CC66 
116                       R=102 G=204 B=204 #66CCCC &hCCCC66 0xCCCC66 
117                       R=102 G=204 B=255 #66CCFF &hFFCC66 0xFFCC66 
118                       R=102 G=255 B=  0 #66FF00 &h00FF66 0x00FF66 
119                       R=102 G=255 B= 51 #66FF33 &h33FF66 0x33FF66 
120                       R=102 G=255 B=102 #66FF66 &h66FF66 0x66FF66 
121                       R=102 G=255 B=153 #66FF99 &h99FF66 0x99FF66 
122                       R=102 G=255 B=204 #66FFCC &hCCFF66 0xCCFF66 
123                       R=102 G=255 B=255 #66FFFF &hFFFF66 0xFFFF66 
124                       R=153 G=  0 B=  0 #990000 &h000099 0x000099 
125                       R=153 G=  0 B= 51 #990033 &h330099 0x330099 
126                       R=153 G=  0 B=102 #990066 &h660099 0x660099 
127                       R=153 G=  0 B=153 #990099 &h990099 0x990099 
128                       R=153 G=  0 B=204 #9900CC &hCC0099 0xCC0099 
129                       R=153 G=  0 B=255 #9900FF &hFF0099 0xFF0099 
130                       R=153 G= 51 B=  0 #993300 &h003399 0x003399 
131                       R=153 G= 51 B= 51 #993333 &h333399 0x333399 
132                       R=153 G= 51 B=102 #993366 &h663399 0x663399 
133                       R=153 G= 51 B=153 #993399 &h993399 0x993399 
134                       R=153 G= 51 B=204 #9933CC &hCC3399 0xCC3399 
135                       R=153 G= 51 B=255 #9933FF &hFF3399 0xFF3399 
136                       R=153 G=102 B=  0 #996600 &h006699 0x006699 
137                       R=153 G=102 B= 51 #996633 &h336699 0x336699 
138                       R=153 G=102 B=102 #996666 &h666699 0x666699 
139                       R=153 G=102 B=153 #996699 &h996699 0x996699 
140                       R=153 G=102 B=204 #9966CC &hCC6699 0xCC6699 
141                       R=153 G=102 B=255 #9966FF &hFF6699 0xFF6699 
142                       R=153 G=153 B=  0 #999900 &h009999 0x009999 
143                       R=153 G=153 B= 51 #999933 &h339999 0x339999 
144                       R=153 G=153 B=102 #999966 &h669999 0x669999 
145                       R=153 G=153 B=153 #999999 &h999999 0x999999 
146                       R=153 G=153 B=204 #9999CC &hCC9999 0xCC9999 
147                       R=153 G=153 B=255 #9999FF &hFF9999 0xFF9999 
148                       R=153 G=204 B=  0 #99CC00 &h00CC99 0x00CC99 
149                       R=153 G=204 B= 51 #99CC33 &h33CC99 0x33CC99 
150                       R=153 G=204 B=102 #99CC66 &h66CC99 0x66CC99 
151                       R=153 G=204 B=153 #99CC99 &h99CC99 0x99CC99 
152                       R=153 G=204 B=204 #99CCCC &hCCCC99 0xCCCC99 
153                       R=153 G=204 B=255 #99CCFF &hFFCC99 0xFFCC99 
154                       R=153 G=255 B=  0 #99FF00 &h00FF99 0x00FF99 
155                       R=153 G=255 B= 51 #99FF33 &h33FF99 0x33FF99 
156                       R=153 G=255 B=102 #99FF66 &h66FF99 0x66FF99 
157                       R=153 G=255 B=153 #99FF99 &h99FF99 0x99FF99 
158                       R=153 G=255 B=204 #99FFCC &hCCFF99 0xCCFF99 
159                       R=153 G=255 B=255 #99FFFF &hFFFF99 0xFFFF99 
160                       R=204 G=  0 B=  0 #CC0000 &h0000CC 0x0000CC 
161                       R=204 G=  0 B= 51 #CC0033 &h3300CC 0x3300CC 
162                       R=204 G=  0 B=102 #CC0066 &h6600CC 0x6600CC 
163                       R=204 G=  0 B=153 #CC0099 &h9900CC 0x9900CC 
164                       R=204 G=  0 B=204 #CC00CC &hCC00CC 0xCC00CC 
165                       R=204 G=  0 B=255 #CC00FF &hFF00CC 0xFF00CC 
166                       R=204 G= 51 B=  0 #CC3300 &h0033CC 0x0033CC 
167                       R=204 G= 51 B= 51 #CC3333 &h3333CC 0x3333CC 
168                       R=204 G= 51 B=102 #CC3366 &h6633CC 0x6633CC 
169                       R=204 G= 51 B=153 #CC3399 &h9933CC 0x9933CC 
170                       R=204 G= 51 B=204 #CC33CC &hCC33CC 0xCC33CC 
171                       R=204 G= 51 B=255 #CC33FF &hFF33CC 0xFF33CC 
172                       R=204 G=102 B=  0 #CC6600 &h0066CC 0x0066CC 
173                       R=204 G=102 B= 51 #CC6633 &h3366CC 0x3366CC 
174                       R=204 G=102 B=102 #CC6666 &h6666CC 0x6666CC 
175                       R=204 G=102 B=153 #CC6699 &h9966CC 0x9966CC 
176                       R=204 G=102 B=204 #CC66CC &hCC66CC 0xCC66CC 
177                       R=204 G=102 B=255 #CC66FF &hFF66CC 0xFF66CC 
178                       R=204 G=153 B=  0 #CC9900 &h0099CC 0x0099CC 
179                       R=204 G=153 B= 51 #CC9933 &h3399CC 0x3399CC 
180                       R=204 G=153 B=102 #CC9966 &h6699CC 0x6699CC 
181                       R=204 G=153 B=153 #CC9999 &h9999CC 0x9999CC 
182                       R=204 G=153 B=204 #CC99CC &hCC99CC 0xCC99CC 
183                       R=204 G=153 B=255 #CC99FF &hFF99CC 0xFF99CC 
184                       R=204 G=204 B=  0 #CCCC00 &h00CCCC 0x00CCCC 
185                       R=204 G=204 B= 51 #CCCC33 &h33CCCC 0x33CCCC 
186                       R=204 G=204 B=102 #CCCC66 &h66CCCC 0x66CCCC 
187                       R=204 G=204 B=153 #CCCC99 &h99CCCC 0x99CCCC 
188                       R=204 G=204 B=204 #CCCCCC &hCCCCCC 0xCCCCCC 
189                       R=204 G=204 B=255 #CCCCFF &hFFCCCC 0xFFCCCC 
190                       R=204 G=255 B=  0 #CCFF00 &h00FFCC 0x00FFCC 
191                       R=204 G=255 B= 51 #CCFF33 &h33FFCC 0x33FFCC 
192                       R=204 G=255 B=102 #CCFF66 &h66FFCC 0x66FFCC 
193                       R=204 G=255 B=153 #CCFF99 &h99FFCC 0x99FFCC 
194                       R=204 G=255 B=204 #CCFFCC &hCCFFCC 0xCCFFCC 
195                       R=204 G=255 B=255 #CCFFFF &hFFFFCC 0xFFFFCC 
196 (red)                 R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 
197                       R=255 G=  0 B= 51 #FF0033 &h3300FF 0x3300FF 
198                       R=255 G=  0 B=102 #FF0066 &h6600FF 0x6600FF 
199                       R=255 G=  0 B=153 #FF0099 &h9900FF 0x9900FF 
200                       R=255 G=  0 B=204 #FF00CC &hCC00FF 0xCC00FF 
201 (magenta, fuchsia)    R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 
202                       R=255 G= 51 B=  0 #FF3300 &h0033FF 0x0033FF 
203                       R=255 G= 51 B= 51 #FF3333 &h3333FF 0x3333FF 
204                       R=255 G= 51 B=102 #FF3366 &h6633FF 0x6633FF 
205                       R=255 G= 51 B=153 #FF3399 &h9933FF 0x9933FF 
206                       R=255 G= 51 B=204 #FF33CC &hCC33FF 0xCC33FF 
207                       R=255 G= 51 B=255 #FF33FF &hFF33FF 0xFF33FF 
208                       R=255 G=102 B=  0 #FF6600 &h0066FF 0x0066FF 
209                       R=255 G=102 B= 51 #FF6633 &h3366FF 0x3366FF 
210                       R=255 G=102 B=102 #FF6666 &h6666FF 0x6666FF 
211                       R=255 G=102 B=153 #FF6699 &h9966FF 0x9966FF 
212                       R=255 G=102 B=204 #FF66CC &hCC66FF 0xCC66FF 
213                       R=255 G=102 B=255 #FF66FF &hFF66FF 0xFF66FF 
214                       R=255 G=153 B=  0 #FF9900 &h0099FF 0x0099FF 
215                       R=255 G=153 B= 51 #FF9933 &h3399FF 0x3399FF 
216                       R=255 G=153 B=102 #FF9966 &h6699FF 0x6699FF 
217                       R=255 G=153 B=153 #FF9999 &h9999FF 0x9999FF 
218                       R=255 G=153 B=204 #FF99CC &hCC99FF 0xCC99FF 
219                       R=255 G=153 B=255 #FF99FF &hFF99FF 0xFF99FF 
220                       R=255 G=204 B=  0 #FFCC00 &h00CCFF 0x00CCFF 
221                       R=255 G=204 B= 51 #FFCC33 &h33CCFF 0x33CCFF 
222                       R=255 G=204 B=102 #FFCC66 &h66CCFF 0x66CCFF 
223                       R=255 G=204 B=153 #FFCC99 &h99CCFF 0x99CCFF 
224                       R=255 G=204 B=204 #FFCCCC &hCCCCFF 0xCCCCFF 
225                       R=255 G=204 B=255 #FFCCFF &hFFCCFF 0xFFCCFF 
226 (yellow)              R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 
227                       R=255 G=255 B= 51 #FFFF33 &h33FFFF 0x33FFFF 
228                       R=255 G=255 B=102 #FFFF66 &h66FFFF 0x66FFFF 
229                       R=255 G=255 B=153 #FFFF99 &h99FFFF 0x99FFFF 
230                       R=255 G=255 B=204 #FFFFCC &hCCFFFF 0xCCFFFF 
231 (white)               R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 


That looks nice and even. Can someone rescue me from this indecision?
Australia Forum Administrator #32
Various pages (see below) seem to support the notion of a colour cube that has even increments of 51 (hex 0x33) for each element in the cube.

References:

http://world.std.com/~wij/color/
http://www.webreference.com/dev/graphics/palette.html
http://www.help4web.net/webmaster/Color/ColorTables.html
Australia Forum Administrator #33

These are the colour swatches generated with the current code (with 51 spacing as described above):

And, a smaller version without the reference numbers, which shows the colour transitions better:

Amended on Sat 07 Apr 2007 06:17 AM by Nick Gammon
Australia Forum Administrator #34
Quote:

... you would need a second "xTerm" color dialog off the one for changing ansi settings, which would bring up the palette you can edit for them all ...


I don't really see the point in editing all 256 colours. There are so many on offer that the transitions are really quite subtle (see colour swatches above). If you really want to remap them all, use the MapColour script function.
Australia Forum Administrator #35
Quote:

The most common way to handle bad data, in everything I have ever used that had ANSI support, is to just throw out any codes that are invalid.


Well, does this mean:

  • Show the entire (bad) sequence as regular text, making the assumption that it is really intended to be seen.
  • Note the sequence is bad, but still hide it (ie. everything from ESC ... m), as it is clearly a control sequence, and not intended to be seen.
  • Display as much as you can (eg. my earlier example of multiple codes, some of which are good and some are bad) - in other words, skipping (and not displaying) any bad codes in the middle.
  • Process as much as you can, up to the bad code, and then ignore the rest.
  • Process as much as you can, up to the bad code, and then display the rest.


I'm a bit opposed to regarding something like ESC[48;5;101m as "bad" just because you can't process it. To display that on the screen, when it is "obviously" a control sequence, is just going to make the screen look ugly.

So, for example, if I accept ESC[48;5;101m but one day get ESC[48;6;101m I am inclined to quietly drop it (not display it) on the grounds that it some new code I don't know about, but almost certainly not something intended for the player to see.
USA #36
Ack.. Too many things to reply to. Here we go... lol

Quote:
"... and the normal ANSI part at defaults (something Mushclient already violates. lol)"

In what way?


Mushclient violates the rule of not changing the base 16 ANSI colors because we "can" already edit them. ".pal" files generally have the first 16 and the last 8? as default settings, this was a convention from the old days where the applications had to use the same color palette as the OS, so if you changed the first 16 or the grey scale either a) Your the OS would replace the images first 16 and last 8 with its standards, messing up the picture, or in more unusual cases, the applications colors would get changed to match the image (which in some cases could be very bad). So, Mushclient is violating the rules by allowing you to change those colors.

This is however irrelevant, unless someone expects those colors to be defaults and your text gets messed up somehow because of it. But if that is the case, there is nothing to prevent you from changing back to the normal set.

Quote:
I am inclined to agree with Shaun here. It is all very well wanting 500 colours in the picker, but it then gets unwieldy.

It is very easy to choose a colour like "powderblue" and then adjust the RGB sliders to modify the colour slightly, or click "other colour" to open the standard Windows colour picker, and then move the luminance slider, if you want to change the brightness of it.


Umm. Thinking more in terms of the script. If you want "powderblue4", you can't tell it, "Use powderblue, but make it X% darker." You would have to return the actual RGB color for it, break that into its components, calculate the darker/lighter color, glue the conponents back together, then send that result to through the colornote command. One way to make it less unwieldy in the picker would be to just add a check box that would sort through the colors and only show the "main" set. I.e., anything that showed up as "powderblue(n)" would be tossed, giving the original list. And one of the most frustrating problems I had when looking for a color value was trying to remember what I used some place else. Sure, you can look through your code. Sure, you can look through the main world to see what you set an alternate color to, sure, you can "find" it, but it would be a lot easier to find if it either already had, or you could give it a name.

I remember, for example, that the "Brown" definition in POVRay never looked right, it was more red than it should have been. Maybe someone *wants* to use that color so would call it "MyBrown", just as about 90% of us added a "MyBrown" or "TrueBrown" definition to the file to fix it. (The original ran on the Commodore Amiga, and apparently something odd about the hardware meant that what we see as a correct brown color looked too green, so they had to originally make it more red to compensate.)

Quote:
Vim is a text editor which is Vi IMproved. The .vim files are colour schemes for the editor. The screenshot just above all the .vim files is a screenshot of someone using vim to edit some code.


Thanks. I did look at the files and did mention that I suspected this was the case. The page it was on wasn't, like most that assume you know what the files do already, too specific about that.

Quote:
* Show the entire (bad) sequence as regular text, making the assumption that it is really intended to be seen.

* Note the sequence is bad, but still hide it (ie. everything from ESC ... m), as it is clearly a control sequence, and not intended to be seen.

* Display as much as you can (eg. my earlier example of multiple codes, some of which are good and some are bad) - in other words, skipping (and not displaying) any bad codes in the middle.

* Process as much as you can, up to the bad code, and then ignore the rest.

* Process as much as you can, up to the bad code, and then display the rest.


In my experience, going clear back to BBSes, its more or less something between all 4. If something went screwy with a sequence like "esc[32;1;194mesc[45;0m" and you ended up with "[32;1mesc[45;qm" The result would be: "[32;1mm", since the second set would be seen, but do to the incorrect termination, processing ends the moment it hits the bad data, taking the offending invalid character with it. I think it ignores numbers though, so you could do something like esc[32;5;4;99;5;6m and it would just throw out the invalid values, but if a character landed in there some place, instead of a number, it would immediately terminate, usually only doing what that final character specified, so "m" sets a color, while "s" would "only" do what that character designates. The only source I have is, I think, is in ML for DOS3.3 or something and there is no telling if MS followed spec either. lol
Amended on Sat 07 Apr 2007 09:43 PM by Nick Gammon
USA #37
Umm. Note, I think your example of "ESC[48;6;101m" will still set the color, but it would ignore the "blink: rapid" command in the middle. XTerms color implimenation actually only works because most implimentations allow "ESC[n[;k]m", but ignore cases of "ESC[n[;k][;k]...m" There is nothing in the spec specifically preventing that, but I don't think ANSI.SYS allowed it and I don't know of any other that did either. The page on wikipedia for it

http://en.wikipedia.org/wiki/ANSI_escape_code

gives a mess of totally unsupported codes, of which ANSI in most clients will probably only support the same subset as ANSI.SYS did. Its a throwback to when some applications required that to be installed for color support to work in text clients for DOS and BBSes. A lot of stuff in telnet game clients are throwbacks to those days.
Australia Forum Administrator #38
Quote:

You would have to return the actual RGB color for it, break that into its components, calculate the darker/lighter color, glue the conponents back together, then send that result to through the colornote command.


See: http://www.gammon.com.au/scripts/doc.php?function=AdjustColour
USA #39
Quote:
Mushclient violates the rule of not changing the base 16 ANSI colors because we "can" already edit them. ".pal" files generally have the first 16 and the last 8? as default settings, this was a convention from the old days where the applications had to use the same color palette as the OS, so if you changed the first 16 or the grey scale either a) Your the OS would replace the images first 16 and last 8 with its standards, messing up the picture, or in more unusual cases, the applications colors would get changed to match the image (which in some cases could be very bad). So, Mushclient is violating the rules by allowing you to change those colors.

So are you suggesting a regression here? The reason that MUSHclient does not violate ANSI standards for this is because MC will display whatever colour the colour codes said to. You can alter how these codes look, similar to changing the palate 15 years ago. If you want to have them go back to a standard definition, there is a button in the ANSI colour section to allow you to go back to the normal colours.

Quote:
Umm. Thinking more in terms of the script. If you want "powderblue4", you can't tell it, "Use powderblue, but make it X% darker." You would have to return the actual RGB color for it, break that into its components, calculate the darker/lighter color, glue the conponents back together, then send that result to through the colornote command.

So when I use the hexadecimal codes or use AdjustColour for ColourNote, what exactly am I doing? Am I just wasting typing and not changing the colour displayed at all? I could have sworn that works in all of my plugins, including the one that uses this to have gradients in the colour displayed in a line of text. Must be my imagination.


And once again, I have to mention that MUSHclient is open source. If you feel this strongly about something that the main developer does not agree with, start coding.
Amended on Sat 07 Apr 2007 10:02 PM by Shaun Biggs
Australia Forum Administrator #40
Quote:

Mushclient violates the rule of not changing the base 16 ANSI colors ...


Ah, I thought you were going to object I didn't have the right codes for the 16 base colours.




I know this is now a long thread, but two things I wanted to check are:

  1. Are we agreed that the 6x6x6 colour cube is the correct one? The one shown most recently, with a gap of 51 between each RGB value?
  2. Are we agreed that if the "inverse" attribute is currently set, then the set foreground/background sense is reversed (see earlier post).

Australia Forum Administrator #41
Quote:

At least one Linux/Unix based list of web colors I found included about 4-5 times as many, since it allowed for things like "Light Rose 2", "Light Rose", "Dark Rose 2" and "Dark Rose", instead of just "Rose", or even Light and Dark versions only.


I should point out also that, AFAIK, zMUD has MXP support for the exact same list of colours as MUSHclient, and I don't want to encourage a "client war" where multiple clients all support different colour names, and thus MUD developers aren't sure which colours they can safely use when writing MXP. At least, at present, any colour in the MUSHclient colour picker should be supported.
Australia Forum Administrator #42
For the benefit of other client developers, here is the code I eventually used to generate all 256 entries:


// defines in case you are not using Windows:

// typedef unsigned long  COLORREF;
// typedef unsigned char  BYTE;
// typedef unsigned short WORD;
// #define RGB(r,g,b)  ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
 

COLORREF xterm_256_colours [256];


void Generate256colours (void)
  {

  // standard 16 ANSI colours

  xterm_256_colours   [0] = RGB (0, 0, 0);         // (black)       
  xterm_256_colours   [1] = RGB (128, 0, 0);       // (maroon)      
  xterm_256_colours   [2] = RGB (0, 128, 0);       // (green)       
  xterm_256_colours   [3] = RGB (128, 128, 0);     // (olive)       
  xterm_256_colours   [4] = RGB (0, 0, 128);       // (navy)        
  xterm_256_colours   [5] = RGB (128, 0, 128);     // (purple)      
  xterm_256_colours   [6] = RGB (0, 128, 128);     // (teal)        
  xterm_256_colours   [7] = RGB (192, 192, 192);   // (silver)      
                       
  xterm_256_colours   [8]  = RGB (128, 128, 128);  // (gray)                 
  xterm_256_colours   [9]  = RGB (255, 0, 0);      // (red)               
  xterm_256_colours   [10] = RGB (0, 255, 0);      // (lime)              
  xterm_256_colours   [11] = RGB (255, 255, 0);    // (yellow)            
  xterm_256_colours   [12] = RGB (0, 0, 255);      // (blue)              
  xterm_256_colours   [13] = RGB (255, 0, 255);    // (magenta)  
  xterm_256_colours   [14] = RGB (0, 255, 255);    // (cyan)        
  xterm_256_colours   [15] = RGB (255, 255, 255);  // (white)             

// This gives even 6x6x6 colour cube
//  there are 6 colours in the cube, but only 5 gaps:
//   Thus the colours will be: 0x00 / 0x33 / 0x66 / 0x99 / 0xCC / 0xFF

  const BYTE colour_increment = 255 / 5;     // that is, 51 (0x33)

  int red, green, blue;

  for (red = 0; red < 6; red++)
      for (green = 0; green < 6; green++)
        for (blue = 0; blue < 6; blue++)
           xterm_256_colours [16 + (red * 36) + (blue * 6) + green] =
              RGB (red   * colour_increment, 
                   blue  * colour_increment, 
                   green * colour_increment);


  // finish off with 24 greyscale colours  

  int grey;
  for (grey = 0; grey < 24; grey++)
    {
    BYTE value = 8 + (grey * 10);
    xterm_256_colours [232 + grey] = RGB (value, value, value);
    }

  } // end of Generate256colours

Amended on Sat 07 Apr 2007 11:00 PM by Nick Gammon
USA #43
Quote:
So are you suggesting a regression here?


No, I just mentioned that based on the way palettes where normally handled, it violated the standard, not that we should revert it. Sheesh...

Quote:
So when I use the hexadecimal codes or use AdjustColour for ColourNote, what exactly am I doing? Am I just wasting typing and not changing the colour displayed at all?



Moved discussion about custom colours to:


http://www.gammon.com.au/forum/?id=7775


- Nick Gammon
Amended on Sun 08 Apr 2007 09:03 PM by Nick Gammon
USA #44
Quote:
Its not like, if you allowed naming of user customized colors, that those would be supported in MXP either, it just makes it easier to use the name given to them, rather than trying to remember the hex codes.

So it's easier to remember a whole bunch of different names for colours? I personally would find that much more difficult to do. If you want to add in the colour names to plugins, just define them in the plugin.

<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE muclient[
  <!ENTITY player_name 
   "Balaam" >
  <!ENTITY info_colour
   "11" >
]>


These are the first 7 lines of a plugin I made to keep track of player kills. I put in entities so that people could change their name and the colour which they preferred for display. Every time the player's name is in a trigger, &player_name is substituted so that the triggers don't have to be changed one by one for everyone using the script.
USA #45
Quote:
Are we agreed that the 6x6x6 colour cube is the correct one?
Nick, yes, that color cube is consistent with what I have seen elsewhere.
Australia Forum Administrator #46
Please make posts about adding to the colour picker to this thread:

http://www.gammon.com.au/forum/?id=7775
Australia Forum Administrator #47
After some more agonizing and discussion I have decided to revert to the Xterm colour cube from version 4.96 of MUSHclient. The Xterm cube favours brighter colours (the gap between colours is: 95 / 40 / 40 / 40 / 40).

The Netscape cube, used previously, has even colours, with a consistent gap of 51 / 51 / 51 / 51 / 51.

For backwards compatibility you can change to the Netscape cube by executing this Lua function call:


utils.colourcube (2)  -- Netscape cube


And you can change back to the Xterm cube by doing this:


utils.colourcube (1)  -- Xterm cube


This is a global change as the colour cube table is shared amongst all open worlds.

The current ANSI-256 codes will now be:


0 (black)                 R=  0 G=  0 B=  0 #000000 &h000000 0x000000 00000000
1 (maroon)                R=128 G=  0 B=  0 #800000 &h000080 0x000080 00000128
2 (green)                 R=  0 G=128 B=  0 #008000 &h008000 0x008000 00032768
3 (olive)                 R=128 G=128 B=  0 #808000 &h008080 0x008080 00032896
4 (navy)                  R=  0 G=  0 B=128 #000080 &h800000 0x800000 08388608
5 (purple)                R=128 G=  0 B=128 #800080 &h800080 0x800080 08388736
6 (teal)                  R=  0 G=128 B=128 #008080 &h808000 0x808000 08421376
7 (silver)                R=192 G=192 B=192 #C0C0C0 &hC0C0C0 0xC0C0C0 12632256
8 (gray)                  R=128 G=128 B=128 #808080 &h808080 0x808080 08421504
9 (red)                   R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 00000255
10 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 00065280
11 (yellow)               R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 00065535
12 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 16711680
13 (magenta, fuchsia)     R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 16711935
14 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 16776960
15 (white)                R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 16777215
16 (black)                R=  0 G=  0 B=  0 #000000 &h000000 0x000000 00000000
17                        R=  0 G=  0 B= 95 #00005F &h5F0000 0x5F0000 06225920
18                        R=  0 G=  0 B=135 #000087 &h870000 0x870000 08847360
19                        R=  0 G=  0 B=175 #0000AF &hAF0000 0xAF0000 11468800
20                        R=  0 G=  0 B=215 #0000D7 &hD70000 0xD70000 14090240
21 (blue)                 R=  0 G=  0 B=255 #0000FF &hFF0000 0xFF0000 16711680
22                        R=  0 G= 95 B=  0 #005F00 &h005F00 0x005F00 00024320
23                        R=  0 G= 95 B= 95 #005F5F &h5F5F00 0x5F5F00 06250240
24                        R=  0 G= 95 B=135 #005F87 &h875F00 0x875F00 08871680
25                        R=  0 G= 95 B=175 #005FAF &hAF5F00 0xAF5F00 11493120
26                        R=  0 G= 95 B=215 #005FD7 &hD75F00 0xD75F00 14114560
27                        R=  0 G= 95 B=255 #005FFF &hFF5F00 0xFF5F00 16736000
28                        R=  0 G=135 B=  0 #008700 &h008700 0x008700 00034560
29                        R=  0 G=135 B= 95 #00875F &h5F8700 0x5F8700 06260480
30                        R=  0 G=135 B=135 #008787 &h878700 0x878700 08881920
31                        R=  0 G=135 B=175 #0087AF &hAF8700 0xAF8700 11503360
32                        R=  0 G=135 B=215 #0087D7 &hD78700 0xD78700 14124800
33                        R=  0 G=135 B=255 #0087FF &hFF8700 0xFF8700 16746240
34                        R=  0 G=175 B=  0 #00AF00 &h00AF00 0x00AF00 00044800
35                        R=  0 G=175 B= 95 #00AF5F &h5FAF00 0x5FAF00 06270720
36                        R=  0 G=175 B=135 #00AF87 &h87AF00 0x87AF00 08892160
37                        R=  0 G=175 B=175 #00AFAF &hAFAF00 0xAFAF00 11513600
38                        R=  0 G=175 B=215 #00AFD7 &hD7AF00 0xD7AF00 14135040
39                        R=  0 G=175 B=255 #00AFFF &hFFAF00 0xFFAF00 16756480
40                        R=  0 G=215 B=  0 #00D700 &h00D700 0x00D700 00055040
41                        R=  0 G=215 B= 95 #00D75F &h5FD700 0x5FD700 06280960
42                        R=  0 G=215 B=135 #00D787 &h87D700 0x87D700 08902400
43                        R=  0 G=215 B=175 #00D7AF &hAFD700 0xAFD700 11523840
44                        R=  0 G=215 B=215 #00D7D7 &hD7D700 0xD7D700 14145280
45                        R=  0 G=215 B=255 #00D7FF &hFFD700 0xFFD700 16766720
46 (lime)                 R=  0 G=255 B=  0 #00FF00 &h00FF00 0x00FF00 00065280
47                        R=  0 G=255 B= 95 #00FF5F &h5FFF00 0x5FFF00 06291200
48                        R=  0 G=255 B=135 #00FF87 &h87FF00 0x87FF00 08912640
49                        R=  0 G=255 B=175 #00FFAF &hAFFF00 0xAFFF00 11534080
50                        R=  0 G=255 B=215 #00FFD7 &hD7FF00 0xD7FF00 14155520
51 (cyan, aqua)           R=  0 G=255 B=255 #00FFFF &hFFFF00 0xFFFF00 16776960
52                        R= 95 G=  0 B=  0 #5F0000 &h00005F 0x00005F 00000095
53                        R= 95 G=  0 B= 95 #5F005F &h5F005F 0x5F005F 06226015
54                        R= 95 G=  0 B=135 #5F0087 &h87005F 0x87005F 08847455
55                        R= 95 G=  0 B=175 #5F00AF &hAF005F 0xAF005F 11468895
56                        R= 95 G=  0 B=215 #5F00D7 &hD7005F 0xD7005F 14090335
57                        R= 95 G=  0 B=255 #5F00FF &hFF005F 0xFF005F 16711775
58                        R= 95 G= 95 B=  0 #5F5F00 &h005F5F 0x005F5F 00024415
59                        R= 95 G= 95 B= 95 #5F5F5F &h5F5F5F 0x5F5F5F 06250335
60                        R= 95 G= 95 B=135 #5F5F87 &h875F5F 0x875F5F 08871775
61                        R= 95 G= 95 B=175 #5F5FAF &hAF5F5F 0xAF5F5F 11493215
62                        R= 95 G= 95 B=215 #5F5FD7 &hD75F5F 0xD75F5F 14114655
63                        R= 95 G= 95 B=255 #5F5FFF &hFF5F5F 0xFF5F5F 16736095
64                        R= 95 G=135 B=  0 #5F8700 &h00875F 0x00875F 00034655
65                        R= 95 G=135 B= 95 #5F875F &h5F875F 0x5F875F 06260575
66                        R= 95 G=135 B=135 #5F8787 &h87875F 0x87875F 08882015
67                        R= 95 G=135 B=175 #5F87AF &hAF875F 0xAF875F 11503455
68                        R= 95 G=135 B=215 #5F87D7 &hD7875F 0xD7875F 14124895
69                        R= 95 G=135 B=255 #5F87FF &hFF875F 0xFF875F 16746335
70                        R= 95 G=175 B=  0 #5FAF00 &h00AF5F 0x00AF5F 00044895
71                        R= 95 G=175 B= 95 #5FAF5F &h5FAF5F 0x5FAF5F 06270815
72                        R= 95 G=175 B=135 #5FAF87 &h87AF5F 0x87AF5F 08892255
73                        R= 95 G=175 B=175 #5FAFAF &hAFAF5F 0xAFAF5F 11513695
74                        R= 95 G=175 B=215 #5FAFD7 &hD7AF5F 0xD7AF5F 14135135
75                        R= 95 G=175 B=255 #5FAFFF &hFFAF5F 0xFFAF5F 16756575
76                        R= 95 G=215 B=  0 #5FD700 &h00D75F 0x00D75F 00055135
77                        R= 95 G=215 B= 95 #5FD75F &h5FD75F 0x5FD75F 06281055
78                        R= 95 G=215 B=135 #5FD787 &h87D75F 0x87D75F 08902495
79                        R= 95 G=215 B=175 #5FD7AF &hAFD75F 0xAFD75F 11523935
80                        R= 95 G=215 B=215 #5FD7D7 &hD7D75F 0xD7D75F 14145375
81                        R= 95 G=215 B=255 #5FD7FF &hFFD75F 0xFFD75F 16766815
82                        R= 95 G=255 B=  0 #5FFF00 &h00FF5F 0x00FF5F 00065375
83                        R= 95 G=255 B= 95 #5FFF5F &h5FFF5F 0x5FFF5F 06291295
84                        R= 95 G=255 B=135 #5FFF87 &h87FF5F 0x87FF5F 08912735
85                        R= 95 G=255 B=175 #5FFFAF &hAFFF5F 0xAFFF5F 11534175
86                        R= 95 G=255 B=215 #5FFFD7 &hD7FF5F 0xD7FF5F 14155615
87                        R= 95 G=255 B=255 #5FFFFF &hFFFF5F 0xFFFF5F 16777055
88                        R=135 G=  0 B=  0 #870000 &h000087 0x000087 00000135
89                        R=135 G=  0 B= 95 #87005F &h5F0087 0x5F0087 06226055
90                        R=135 G=  0 B=135 #870087 &h870087 0x870087 08847495
91                        R=135 G=  0 B=175 #8700AF &hAF0087 0xAF0087 11468935
92                        R=135 G=  0 B=215 #8700D7 &hD70087 0xD70087 14090375
93                        R=135 G=  0 B=255 #8700FF &hFF0087 0xFF0087 16711815
94                        R=135 G= 95 B=  0 #875F00 &h005F87 0x005F87 00024455
95                        R=135 G= 95 B= 95 #875F5F &h5F5F87 0x5F5F87 06250375
96                        R=135 G= 95 B=135 #875F87 &h875F87 0x875F87 08871815
97                        R=135 G= 95 B=175 #875FAF &hAF5F87 0xAF5F87 11493255
98                        R=135 G= 95 B=215 #875FD7 &hD75F87 0xD75F87 14114695
99                        R=135 G= 95 B=255 #875FFF &hFF5F87 0xFF5F87 16736135
100                       R=135 G=135 B=  0 #878700 &h008787 0x008787 00034695
101                       R=135 G=135 B= 95 #87875F &h5F8787 0x5F8787 06260615
102                       R=135 G=135 B=135 #878787 &h878787 0x878787 08882055
103                       R=135 G=135 B=175 #8787AF &hAF8787 0xAF8787 11503495
104                       R=135 G=135 B=215 #8787D7 &hD78787 0xD78787 14124935
105                       R=135 G=135 B=255 #8787FF &hFF8787 0xFF8787 16746375
106                       R=135 G=175 B=  0 #87AF00 &h00AF87 0x00AF87 00044935
107                       R=135 G=175 B= 95 #87AF5F &h5FAF87 0x5FAF87 06270855
108                       R=135 G=175 B=135 #87AF87 &h87AF87 0x87AF87 08892295
109                       R=135 G=175 B=175 #87AFAF &hAFAF87 0xAFAF87 11513735
110                       R=135 G=175 B=215 #87AFD7 &hD7AF87 0xD7AF87 14135175
111                       R=135 G=175 B=255 #87AFFF &hFFAF87 0xFFAF87 16756615
112                       R=135 G=215 B=  0 #87D700 &h00D787 0x00D787 00055175
113                       R=135 G=215 B= 95 #87D75F &h5FD787 0x5FD787 06281095
114                       R=135 G=215 B=135 #87D787 &h87D787 0x87D787 08902535
115                       R=135 G=215 B=175 #87D7AF &hAFD787 0xAFD787 11523975
116                       R=135 G=215 B=215 #87D7D7 &hD7D787 0xD7D787 14145415
117                       R=135 G=215 B=255 #87D7FF &hFFD787 0xFFD787 16766855
118                       R=135 G=255 B=  0 #87FF00 &h00FF87 0x00FF87 00065415
119                       R=135 G=255 B= 95 #87FF5F &h5FFF87 0x5FFF87 06291335
120                       R=135 G=255 B=135 #87FF87 &h87FF87 0x87FF87 08912775
121                       R=135 G=255 B=175 #87FFAF &hAFFF87 0xAFFF87 11534215
122                       R=135 G=255 B=215 #87FFD7 &hD7FF87 0xD7FF87 14155655
123                       R=135 G=255 B=255 #87FFFF &hFFFF87 0xFFFF87 16777095
124                       R=175 G=  0 B=  0 #AF0000 &h0000AF 0x0000AF 00000175
125                       R=175 G=  0 B= 95 #AF005F &h5F00AF 0x5F00AF 06226095
126                       R=175 G=  0 B=135 #AF0087 &h8700AF 0x8700AF 08847535
127                       R=175 G=  0 B=175 #AF00AF &hAF00AF 0xAF00AF 11468975
128                       R=175 G=  0 B=215 #AF00D7 &hD700AF 0xD700AF 14090415
129                       R=175 G=  0 B=255 #AF00FF &hFF00AF 0xFF00AF 16711855
130                       R=175 G= 95 B=  0 #AF5F00 &h005FAF 0x005FAF 00024495
131                       R=175 G= 95 B= 95 #AF5F5F &h5F5FAF 0x5F5FAF 06250415
132                       R=175 G= 95 B=135 #AF5F87 &h875FAF 0x875FAF 08871855
133                       R=175 G= 95 B=175 #AF5FAF &hAF5FAF 0xAF5FAF 11493295
134                       R=175 G= 95 B=215 #AF5FD7 &hD75FAF 0xD75FAF 14114735
135                       R=175 G= 95 B=255 #AF5FFF &hFF5FAF 0xFF5FAF 16736175
136                       R=175 G=135 B=  0 #AF8700 &h0087AF 0x0087AF 00034735
137                       R=175 G=135 B= 95 #AF875F &h5F87AF 0x5F87AF 06260655
138                       R=175 G=135 B=135 #AF8787 &h8787AF 0x8787AF 08882095
139                       R=175 G=135 B=175 #AF87AF &hAF87AF 0xAF87AF 11503535
140                       R=175 G=135 B=215 #AF87D7 &hD787AF 0xD787AF 14124975
141                       R=175 G=135 B=255 #AF87FF &hFF87AF 0xFF87AF 16746415
142                       R=175 G=175 B=  0 #AFAF00 &h00AFAF 0x00AFAF 00044975
143                       R=175 G=175 B= 95 #AFAF5F &h5FAFAF 0x5FAFAF 06270895
144                       R=175 G=175 B=135 #AFAF87 &h87AFAF 0x87AFAF 08892335
145                       R=175 G=175 B=175 #AFAFAF &hAFAFAF 0xAFAFAF 11513775
146                       R=175 G=175 B=215 #AFAFD7 &hD7AFAF 0xD7AFAF 14135215
147                       R=175 G=175 B=255 #AFAFFF &hFFAFAF 0xFFAFAF 16756655
148                       R=175 G=215 B=  0 #AFD700 &h00D7AF 0x00D7AF 00055215
149                       R=175 G=215 B= 95 #AFD75F &h5FD7AF 0x5FD7AF 06281135
150                       R=175 G=215 B=135 #AFD787 &h87D7AF 0x87D7AF 08902575
151                       R=175 G=215 B=175 #AFD7AF &hAFD7AF 0xAFD7AF 11524015
152                       R=175 G=215 B=215 #AFD7D7 &hD7D7AF 0xD7D7AF 14145455
153                       R=175 G=215 B=255 #AFD7FF &hFFD7AF 0xFFD7AF 16766895
154                       R=175 G=255 B=  0 #AFFF00 &h00FFAF 0x00FFAF 00065455
155                       R=175 G=255 B= 95 #AFFF5F &h5FFFAF 0x5FFFAF 06291375
156                       R=175 G=255 B=135 #AFFF87 &h87FFAF 0x87FFAF 08912815
157                       R=175 G=255 B=175 #AFFFAF &hAFFFAF 0xAFFFAF 11534255
158                       R=175 G=255 B=215 #AFFFD7 &hD7FFAF 0xD7FFAF 14155695
159                       R=175 G=255 B=255 #AFFFFF &hFFFFAF 0xFFFFAF 16777135
160                       R=215 G=  0 B=  0 #D70000 &h0000D7 0x0000D7 00000215
161                       R=215 G=  0 B= 95 #D7005F &h5F00D7 0x5F00D7 06226135
162                       R=215 G=  0 B=135 #D70087 &h8700D7 0x8700D7 08847575
163                       R=215 G=  0 B=175 #D700AF &hAF00D7 0xAF00D7 11469015
164                       R=215 G=  0 B=215 #D700D7 &hD700D7 0xD700D7 14090455
165                       R=215 G=  0 B=255 #D700FF &hFF00D7 0xFF00D7 16711895
166                       R=215 G= 95 B=  0 #D75F00 &h005FD7 0x005FD7 00024535
167                       R=215 G= 95 B= 95 #D75F5F &h5F5FD7 0x5F5FD7 06250455
168                       R=215 G= 95 B=135 #D75F87 &h875FD7 0x875FD7 08871895
169                       R=215 G= 95 B=175 #D75FAF &hAF5FD7 0xAF5FD7 11493335
170                       R=215 G= 95 B=215 #D75FD7 &hD75FD7 0xD75FD7 14114775
171                       R=215 G= 95 B=255 #D75FFF &hFF5FD7 0xFF5FD7 16736215
172                       R=215 G=135 B=  0 #D78700 &h0087D7 0x0087D7 00034775
173                       R=215 G=135 B= 95 #D7875F &h5F87D7 0x5F87D7 06260695
174                       R=215 G=135 B=135 #D78787 &h8787D7 0x8787D7 08882135
175                       R=215 G=135 B=175 #D787AF &hAF87D7 0xAF87D7 11503575
176                       R=215 G=135 B=215 #D787D7 &hD787D7 0xD787D7 14125015
177                       R=215 G=135 B=255 #D787FF &hFF87D7 0xFF87D7 16746455
178                       R=215 G=175 B=  0 #D7AF00 &h00AFD7 0x00AFD7 00045015
179                       R=215 G=175 B= 95 #D7AF5F &h5FAFD7 0x5FAFD7 06270935
180                       R=215 G=175 B=135 #D7AF87 &h87AFD7 0x87AFD7 08892375
181                       R=215 G=175 B=175 #D7AFAF &hAFAFD7 0xAFAFD7 11513815
182                       R=215 G=175 B=215 #D7AFD7 &hD7AFD7 0xD7AFD7 14135255
183                       R=215 G=175 B=255 #D7AFFF &hFFAFD7 0xFFAFD7 16756695
184                       R=215 G=215 B=  0 #D7D700 &h00D7D7 0x00D7D7 00055255
185                       R=215 G=215 B= 95 #D7D75F &h5FD7D7 0x5FD7D7 06281175
186                       R=215 G=215 B=135 #D7D787 &h87D7D7 0x87D7D7 08902615
187                       R=215 G=215 B=175 #D7D7AF &hAFD7D7 0xAFD7D7 11524055
188                       R=215 G=215 B=215 #D7D7D7 &hD7D7D7 0xD7D7D7 14145495
189                       R=215 G=215 B=255 #D7D7FF &hFFD7D7 0xFFD7D7 16766935
190                       R=215 G=255 B=  0 #D7FF00 &h00FFD7 0x00FFD7 00065495
191                       R=215 G=255 B= 95 #D7FF5F &h5FFFD7 0x5FFFD7 06291415
192                       R=215 G=255 B=135 #D7FF87 &h87FFD7 0x87FFD7 08912855
193                       R=215 G=255 B=175 #D7FFAF &hAFFFD7 0xAFFFD7 11534295
194                       R=215 G=255 B=215 #D7FFD7 &hD7FFD7 0xD7FFD7 14155735
195                       R=215 G=255 B=255 #D7FFFF &hFFFFD7 0xFFFFD7 16777175
196 (red)                 R=255 G=  0 B=  0 #FF0000 &h0000FF 0x0000FF 00000255
197                       R=255 G=  0 B= 95 #FF005F &h5F00FF 0x5F00FF 06226175
198                       R=255 G=  0 B=135 #FF0087 &h8700FF 0x8700FF 08847615
199                       R=255 G=  0 B=175 #FF00AF &hAF00FF 0xAF00FF 11469055
200                       R=255 G=  0 B=215 #FF00D7 &hD700FF 0xD700FF 14090495
201 (magenta, fuchsia)    R=255 G=  0 B=255 #FF00FF &hFF00FF 0xFF00FF 16711935
202                       R=255 G= 95 B=  0 #FF5F00 &h005FFF 0x005FFF 00024575
203                       R=255 G= 95 B= 95 #FF5F5F &h5F5FFF 0x5F5FFF 06250495
204                       R=255 G= 95 B=135 #FF5F87 &h875FFF 0x875FFF 08871935
205                       R=255 G= 95 B=175 #FF5FAF &hAF5FFF 0xAF5FFF 11493375
206                       R=255 G= 95 B=215 #FF5FD7 &hD75FFF 0xD75FFF 14114815
207                       R=255 G= 95 B=255 #FF5FFF &hFF5FFF 0xFF5FFF 16736255
208                       R=255 G=135 B=  0 #FF8700 &h0087FF 0x0087FF 00034815
209                       R=255 G=135 B= 95 #FF875F &h5F87FF 0x5F87FF 06260735
210                       R=255 G=135 B=135 #FF8787 &h8787FF 0x8787FF 08882175
211                       R=255 G=135 B=175 #FF87AF &hAF87FF 0xAF87FF 11503615
212                       R=255 G=135 B=215 #FF87D7 &hD787FF 0xD787FF 14125055
213                       R=255 G=135 B=255 #FF87FF &hFF87FF 0xFF87FF 16746495
214                       R=255 G=175 B=  0 #FFAF00 &h00AFFF 0x00AFFF 00045055
215                       R=255 G=175 B= 95 #FFAF5F &h5FAFFF 0x5FAFFF 06270975
216                       R=255 G=175 B=135 #FFAF87 &h87AFFF 0x87AFFF 08892415
217                       R=255 G=175 B=175 #FFAFAF &hAFAFFF 0xAFAFFF 11513855
218                       R=255 G=175 B=215 #FFAFD7 &hD7AFFF 0xD7AFFF 14135295
219                       R=255 G=175 B=255 #FFAFFF &hFFAFFF 0xFFAFFF 16756735
220 (gold)                R=255 G=215 B=  0 #FFD700 &h00D7FF 0x00D7FF 00055295
221                       R=255 G=215 B= 95 #FFD75F &h5FD7FF 0x5FD7FF 06281215
222                       R=255 G=215 B=135 #FFD787 &h87D7FF 0x87D7FF 08902655
223                       R=255 G=215 B=175 #FFD7AF &hAFD7FF 0xAFD7FF 11524095
224                       R=255 G=215 B=215 #FFD7D7 &hD7D7FF 0xD7D7FF 14145535
225                       R=255 G=215 B=255 #FFD7FF &hFFD7FF 0xFFD7FF 16766975
226 (yellow)              R=255 G=255 B=  0 #FFFF00 &h00FFFF 0x00FFFF 00065535
227                       R=255 G=255 B= 95 #FFFF5F &h5FFFFF 0x5FFFFF 06291455
228                       R=255 G=255 B=135 #FFFF87 &h87FFFF 0x87FFFF 08912895
229                       R=255 G=255 B=175 #FFFFAF &hAFFFFF 0xAFFFFF 11534335
230                       R=255 G=255 B=215 #FFFFD7 &hD7FFFF 0xD7FFFF 14155775
231 (white)               R=255 G=255 B=255 #FFFFFF &hFFFFFF 0xFFFFFF 16777215
232                       R=  8 G=  8 B=  8 #080808 &h080808 0x080808 00526344
233                       R= 18 G= 18 B= 18 #121212 &h121212 0x121212 01184274
234                       R= 28 G= 28 B= 28 #1C1C1C &h1C1C1C 0x1C1C1C 01842204
235                       R= 38 G= 38 B= 38 #262626 &h262626 0x262626 02500134
236                       R= 48 G= 48 B= 48 #303030 &h303030 0x303030 03158064
237                       R= 58 G= 58 B= 58 #3A3A3A &h3A3A3A 0x3A3A3A 03815994
238                       R= 68 G= 68 B= 68 #444444 &h444444 0x444444 04473924
239                       R= 78 G= 78 B= 78 #4E4E4E &h4E4E4E 0x4E4E4E 05131854
240                       R= 88 G= 88 B= 88 #585858 &h585858 0x585858 05789784
241                       R= 98 G= 98 B= 98 #626262 &h626262 0x626262 06447714
242                       R=108 G=108 B=108 #6C6C6C &h6C6C6C 0x6C6C6C 07105644
243                       R=118 G=118 B=118 #767676 &h767676 0x767676 07763574
244 (gray)                R=128 G=128 B=128 #808080 &h808080 0x808080 08421504
245                       R=138 G=138 B=138 #8A8A8A &h8A8A8A 0x8A8A8A 09079434
246                       R=148 G=148 B=148 #949494 &h949494 0x949494 09737364
247                       R=158 G=158 B=158 #9E9E9E &h9E9E9E 0x9E9E9E 10395294
248                       R=168 G=168 B=168 #A8A8A8 &hA8A8A8 0xA8A8A8 11053224
249                       R=178 G=178 B=178 #B2B2B2 &hB2B2B2 0xB2B2B2 11711154
250                       R=188 G=188 B=188 #BCBCBC &hBCBCBC 0xBCBCBC 12369084
251                       R=198 G=198 B=198 #C6C6C6 &hC6C6C6 0xC6C6C6 13027014
252                       R=208 G=208 B=208 #D0D0D0 &hD0D0D0 0xD0D0D0 13684944
253                       R=218 G=218 B=218 #DADADA &hDADADA 0xDADADA 14342874
254                       R=228 G=228 B=228 #E4E4E4 &hE4E4E4 0xE4E4E4 15000804
255                       R=238 G=238 B=238 #EEEEEE &hEEEEEE 0xEEEEEE 15658734


You can view these colours in the client by doing this Immediate scripting instruction (Ctrl+I):


Debug "colours256"





The code to generate the Xterm cube is:


void Generate256colours (void)
  {
  int red, green, blue;
  const BYTE values [6] = { 
      0, 
     95, 
     95 + 40, 
     95 + 40 + 40, 
     95 + 40 + 40 + 40, 
     95 + 40 + 40 + 40 + 40
      };

  xterm_256_colours   [0] = RGB (0, 0, 0);         // (black)       
  xterm_256_colours   [1] = RGB (128, 0, 0);       // (maroon)      
  xterm_256_colours   [2] = RGB (0, 128, 0);       // (green)       
  xterm_256_colours   [3] = RGB (128, 128, 0);     // (olive)       
  xterm_256_colours   [4] = RGB (0, 0, 128);       // (navy)        
  xterm_256_colours   [5] = RGB (128, 0, 128);     // (purple)      
  xterm_256_colours   [6] = RGB (0, 128, 128);     // (teal)        
  xterm_256_colours   [7] = RGB (192, 192, 192);   // (silver)      
                       
  xterm_256_colours   [8]  = RGB (128, 128, 128);  // (gray)                 
  xterm_256_colours   [9]  = RGB (255, 0, 0);      // (red)               
  xterm_256_colours   [10] = RGB (0, 255, 0);      // (lime)              
  xterm_256_colours   [11] = RGB (255, 255, 0);    // (yellow)            
  xterm_256_colours   [12] = RGB (0, 0, 255);      // (blue)              
  xterm_256_colours   [13] = RGB (255, 0, 255);    // (magenta)  
  xterm_256_colours   [14] = RGB (0, 255, 255);    // (cyan)        
  xterm_256_colours   [15] = RGB (255, 255, 255);  // (white)             

  for (red = 0; red < 6; red++)
    for (green = 0; green < 6; green++)
      for (blue = 0; blue < 6; blue++)
         xterm_256_colours [16 + (red * 36) + (green * 6) + blue] =
            RGB (values [red], values [green], values [blue]);

  int grey;
  for (grey = 0; grey < 24; grey++)
    {
    BYTE value = 8 + (grey * 10);
    xterm_256_colours [232 + grey] = RGB (value, value, value);
    }

  } // end of Generate256colours

Amended on Sun 19 Oct 2014 01:06 AM by Nick Gammon
Australia Forum Administrator #48
Swatches from the new colour cube:




Lua code to generate the above:


values = { 0, 
     95, 
     95 + 40, 
     95 + 40 + 40, 
     95 + 40 + 40 + 40, 
     95 + 40 + 40 + 40 + 40
      };

  which = 16
  
  print (string.rep ("-", 80))
  print""
  
  for red = 0, 5 do
    for green = 0, 5 do
      for blue = 0, 5 do
      
      Tell (string.format (" %3i: ", which))
      ColourTell ("", 
                  RGBColourToName (values [red + 1] + 
                                   values [green + 1] * 256 + 
                                   values [blue + 1] * 65536),  
                                   "    ")
      which = which + 1
      end -- of for each blue
      
    print ""
    end -- of for each green
    
    print ""
  end  -- of for each read
  
  -- grayscale stuff
  
  gray = 8
  
  for line = 1, 4 do
    for col = 1, 6 do
    
     Tell (string.format (" %3i: ", which))
      ColourTell ("", 
                  RGBColourToName (gray + 
                                   gray * 256 + 
                                   gray * 65536),  
                                   "    ")
      which = which + 1
      gray = gray + 10
    end -- for each line
    print ""
  end -- for each col
  
print ""






Swatches with hex codes:



Lua code to generate the above:


values = { 0, 
     95, 
     95 + 40, 
     95 + 40 + 40, 
     95 + 40 + 40 + 40, 
     95 + 40 + 40 + 40 + 40
      };

  which = 16
  
  print (string.rep ("-", 80))
  print""
  
  for red = 0, 5 do
    for green = 0, 5 do
      for blue = 0, 5 do
      colour = values [red + 1] + 
               values [green + 1] * 256 + 
               values [blue + 1] * 65536
      textcolour = "white"
      if values [red + 1] + values [green + 1] + values [blue + 1] > (128 * 3) then
         textcolour = "black"
      end -- if
      ColourTell (textcolour, RGBColourToName (colour), 
                  string.format (" %3i: %02X%02X%02X ", 
                  which, values [red + 1], values [green + 1], values [blue + 1] ))
      Tell " "
      which = which + 1
      end -- of for each blue
      
    print ""
    end -- of for each green
    
    print ""
  end  -- of for each read
  
  -- grayscale stuff
  
  gray = 8
  
  for line = 1, 4 do
    for col = 1, 6 do
    
     colour = gray + 
              gray * 256 + 
              gray * 65536

      textcolour = "white"
      if gray  > 128 then
         textcolour = "black"
      end -- if
      ColourTell (textcolour, RGBColourToName (colour), string.format (" %3i: %06X ", which, colour))
      Tell " "
      which = which + 1
      gray = gray + 10
    end -- for each line
    print ""
  end -- for each col
  
print ""






By way of comparison, here are the "official" colour names used by the client, sorted into "sort of" colour order:



Lua code to generate the above:


  print ""

  t = {}
  for k, v in pairs (colour_names) do
    table.insert (t, k)
  end -- for

  table.sort (t, function (a, b)
           col1 = colour_names [a]
           col2 = colour_names [b]
           r1 = bit.band (col1, 0xFF)
           r2 = bit.band (col2, 0xFF)
           -- slight adjustment so identical colours sort together
           g1 = bit.band (bit.shr (col1, 8), 0xFF) * 1.001
           g2 = bit.band (bit.shr (col2, 8), 0xFF) * 1.001
           b1 = bit.band (bit.shr (col1, 16), 0xFF) * 1.002
           b2 = bit.band (bit.shr (col2, 16), 0xFF) *  1.002

           return r1 + g1 + b1 < r2 + g2 + b2

           end -- function
        )

  which = 0

  print ""

 function showcolour (name)
     colour = colour_names [name]
      r = bit.band (colour, 0xFF)
      g = bit.band (bit.shr (colour, 8), 0xFF)
      b = bit.band (bit.shr (colour, 16), 0xFF)
 
      textcolour = "white"
      if r + g + b > (128 * 3) then
         textcolour = "black"
      end -- if
      ColourTell (textcolour, RGBColourToName (colour), 
                  string.format (" %-20s: %02X%02X%02X ", name, r, g, b ))
      Tell "  "

      which = which + 1
 end -- showcolour

 for i = 1, #t / 3 do
   showcolour (t [i])
   showcolour (t [i + #t / 3 ])
   showcolour (t [i + (#t / 3) * 2])
   print ""

 end -- for

 print ""





And now the "official" colour names used by the client, sorted into alphabetical order:



Lua code to generate the above:


  print ""

  t = {}
  for k, v in pairs (colour_names) do
    table.insert (t, k)
  end -- for

  table.sort (t, function (a, b) return a < b end)

 function showcolour (name)
     colour = colour_names [name]
      r = bit.band (colour, 0xFF)
      g = bit.band (bit.shr (colour, 8), 0xFF)
      b = bit.band (bit.shr (colour, 16), 0xFF)
 
      textcolour = "white"
      if r + g + b > (128 * 3) then
         textcolour = "black"
      end -- if
      ColourTell (textcolour, RGBColourToName (colour), 
                  string.format (" %-20s: %02X%02X%02X ", name, r, g, b ))
      Tell "  "
 end -- showcolour

 for i = 1, #t / 3 do
   showcolour (t [i])
   showcolour (t [i + #t / 3 ])
   showcolour (t [i + (#t / 3) * 2])
   print ""

 end -- for

 print ""