Rhye said:
Here's the tutorial. There's written all that I know right now.
Sorry for my poor English!! I've been hurrying in writing it.
Hmmm, a couple of notes, since you seem to be going on a kind of hit-or-miss method, and this is really a reducable problem. This may prove handy to people who want smooth transitions without hours of testing.
The base color is palette index 7. Everything else is pretty much based off of this color - sloping up toward white in index 6 -> 0, down toward black in 8 -> 15. Odd indexes from 17 -> 63 are other base colors present in the palette. Even indexes from 16 -> 62 are used as transitions between the base color and the following color, and their value is equal to a merge between the base index (7) and the following index. In other words, for even n from 16 -> 62, r(n) = avg(r(7), r(n+1); g(n) = avg(g(7), g(n+1); b(n) = avg(b(7), b(n+1). Indexes 64, 66, 67, and 68 are typically equal to the base index, 65 is some variation of it, and 69 is some darker version. Ok, so far, that's a general description of the single-color definition.
Bi-Color definitions: The secondary index is 10 - the is heavily used as a contrast color to the primary. To do a good bi-color transition which minimizes speckling and harsh crossovers, we need to change a couple of value calculations. First of all, slope 11 -> 15 down from 10 instead of 7. Now set your transition colors in 8 and 9 - third-step merges seem to work very well: r(8) = (r(7)*2 + r(10))/3; r(9) = (r(7) + r(10)*2)/3. This provides two buffer colors which serve as a smooth transition between your two primary colors. For the transition colors in 16 -> 62, we need to make a choice about our base color. It seems to work well if we do this based on brightness, weighted toward our two primary colors. Now our formula for setting the transition colors looks like this:
If (r(n+1) + g(n+1) + b(n+1)) / 3 < 96
r(n) = avg(r(7), r(n+1); g(n) = avg(g(7), g(n+1); b(n) = avg(b(7), b(n+1)
else if (r(n+1) + g(n+1) + b(n+1)) / 3 < 128
r(n) = avg(r(8), r(n+1); g(n) = avg(g(8), g(n+1); b(n) = avg(b(8), b(n+1)
else if (r(n+1) + g(n+1) + b(n+1)) / 3 < 160
r(n) = avg(r(9), r(n+1); g(n) = avg(g(9), g(n+1); b(n) = avg(b(9), b(n+1)
else
r(n) = avg(r(10), r(n+1); g(n) = avg(g(10), g(n+1); b(n) = avg(b(10), b(n+1)
endif
For the border, set 64 = 7, 65 = 8. This will give a border in the primary color, slightly shifted toward the secondary color.
Tri-Color definitions: Treat 0 -> 15 as you would a bi-color definition. Set 67 to your tertiary color. Now, for the transitional colors, you have a choice, since they aren't very prominent, and anything you do here is going to be kinda subtle anyway. For a somewhat more noticable, slightly speckly effect, simply merge 16 -> 62 with 67 instead of either 7 or 10. For a much subtler but very smooth effect, use the if statement from above, but get rid of the < 128 line, and change the < 160 line to use 67 as the base for merging. The attached pcx is a sample of the more abrupt tri-color method. It is an italian white/green/red mix. Red is the tertiary color - note how it shows up mainly as accent striping on certain units. Actually, this one was done by hand, so it's not as smooth as some of the later ones - I'll upload samples in a day or two.
Four- and Five- Color definitions: Treat as a bi-color, but shift 6 -> 0 toward the tertiary color instead of white, and **** 11 -> 15 toward the fourth color instead of black. If using a fifth color, use this as the tertiary color in the tri-color example. These transitions look really good when you use them to control the range of shading on the primary and secondary colors - I'm looking into how well it works with contrasting colors, and I'll upload samples when I get a definitive answer.
If anyone is interested, I've written a little program which lets you select the base colors, then calculates all the appropriate shades, give a graphical display of what the palette should look like, and puts the rgb values into an edit box for you. The language I've written it in isn't a very good one for directly altering the palette, but I can hand the algorithms off to anyone who wants to write something like that, or even alter mine so that it calls a palette editing program with the values to be changed.