## Dfool of many colors

Production of artwork for the game by regular contributors takes place here.

Moderators: Forum Moderators, Developers

yobbo
Art Contributor
Posts: 151
Joined: September 16th, 2005, 6:31 am
Location: New Zealand
Jetryl wrote:
Darth Fool wrote:Now, the question I have is, can this easily be done in RGB space, or should I do it in HSV space? I can imagine that in HSV space one could reduce the number of parameters since presumably the hue should not change, so you would only need to specify the range for the Saturation and Value(or should I say Brightness?)
Yobbo, do you want to figure this out, or shall I commence to ciphering?
Let's see...

Assuming we want to define 3 colours from the TBRS: Rmin, R and Rmax; and 3 colours for the team colour: TCmin, TC and TCmax...

The simplest way to convert a colour X from the TBRS to a colour Y in the TCS would be to map from the value of X. So RGB space should be fine - I think this is pretty much the method Darth Fool's used so far (right?):

Code: Select all

``````val(Z) = max(Zr, Zg, Zb) # red, green, blue

if val(X) < val(Rmin):
X = Rmin
if val(X) > val(Rmax):
X = Rmax

case val(X) <= val(R):
A = ( val(X) - val(Rmin) ) / ( val(R) - val(Rmin) )
Yr = [TCmin]r + A * ( [TC]r - [TCmin]r )
Yg = [TCmin]g + A * ( [TC]g - [TCmin]g )
Yb = [TCmin]b + A * ( [TC]b - [TCmin]b )

case val(X) > val(R):
A = ( val(X) - val(R) ) / ( val(Rmax) - val(R) )
Yr = [TC]r + A * ( [TCmax]r - [TC]r )
etc for Yg, Yb
``````
This would ignore the saturation of X - but it would allow the highlights and lowlights to be manually defined for each team colour.

Oh - if you want absolute limits of white and black for the TBRS, just hard-code Rmin to (0,0,0) and Rmax to (255,255,255) . It might be useful to have these colours editable in WML somehow, though...

Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Well, my current plan is to define three rgb values, the minimum, the maximum, and the team color. For original colors where the total color (r+g+b) is less than the first total, the new color will be a linear combination of the team color and the minimum color, weighted by the ratio of the original color to the first color. Ok, the code might be easier to understand:

Code: Select all

``````  const Uint16 old_avg = (Uint16)(((Uint16) old_r +
(Uint16) old_g +
(Uint16) old_b) / 3);

if(reference_avg && old_avg <= reference_avg){
float old_rat = old_avg/reference_avg;
new_r=(Uint8)( old_rat * new_red   + (1 - old_rat) * min_red);
new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * min_green);                new_b=(Uint8)( old_rat * new_blue  + (1 - old_rat) * min_blue);
}else if(255 - reference_avg){
float old_rat = (255-old_avg)/(255-reference_avg);
new_r=(Uint8)( old_rat * new_red   + (1 - old_rat) * max_red);
new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * max_green);                new_b=(Uint8)( old_rat * new_blue  + (1 - old_rat) * max_blue);
}else{
//should never get here
//would imply old_avg > reference_avg = 255
}
``````
now, this will work reasonably when the min color is black, and the max color is white. Other colors will work as well as long as the min is a darker version of the team color, and the max is a lighter version. Strange things will happen for arbitrary min and max. It, will, for example, be possible to invert the lighting by setting max to black and the min to white, or do stranger things by setting the team color to red, the max to green, and the min to blue. This might be too much freedom, but it is the easiest thing to code and still allow flexibility to change the color range. By default black and white will be used for the min and max respectively. In addition, the fact that the team color range default values will all be WML configurable should allow jetryl and Eleazer enough flexibility to come up with reasonable values.

yobbo
Art Contributor
Posts: 151
Joined: September 16th, 2005, 6:31 am
Location: New Zealand
Darth Fool wrote:Well, my current plan is to define three rgb values, the minimum, the maximum, and the team color. For original colors where the total color (r+g+b) is less than the first total, the new color will be a linear combination of the team color and the minimum color, weighted by the ratio of the original color to the first color.
Yeah, using the sum/average of r/g/b like you are is better than what I said .
Strange things will happen for arbitrary min and max. It, will, for example, be possible to invert the lighting by setting max to black and the min to white, or do stranger things by setting the team color to red, the max to green, and the min to blue.
I like the idea of the Inverted Psychadelic Rainbow team... please leave this possibility in .

Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
Ok, this has now been implemented. team_rgb can now be set to use three rgb values, the first is the team color, the second is the maximum (default white), the third is the minimum (default black). "team_rgb=255,0,0,0,255,0,0,0,255" set in a side tag in a scenario will set the team colors to the psychedelic rainbow. Alternatively, the default values can be set in the new team_colors.cfg. a sample of how to do this for the side=1 has been done. Note that this change also will mean that the first color in flag_rgb in a unit.cfg is now used to set the luminosity used for the team color. Go nuts...

Eleazar
Retired Terrain Art Director
Posts: 2481
Joined: July 16th, 2004, 1:47 am
Location: US Midwest
Contact:

commencing nut-going....
Feel free to PM me if you start a new terrain oriented thread. It's easy for me to miss them among all the other art threads.
-> What i might be working on
Attempting Lucidity

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
Eleazar wrote:

commencing nut-going....
Indeed. #jetryl is nuts about dfool's patch

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
I've updated the macro to use the existing team colors I had already defined for horsemen et. al. correctly.

Once I get more units in, the "thing to do" will be to look at how the team colors are used on these units, and imitate that when team coloring a unit.

turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:
So, uh... which pallette of magenta colors should we use to get tcolor done correctly?
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
Attachments
TCPatch-on.png (190.42 KiB) Viewed 4496 times
TCPatch-off.png (151.54 KiB) Viewed 4497 times
TCPatch-alone.png (37.71 KiB) Viewed 4497 times

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
turin wrote:So, uh... which pallette of magenta colors should we use to get tcolor done correctly?
Ahem:
http://www.wesnoth.org/wiki/Team_Color_Shifting

Woodwizzle
Posts: 719
Joined: December 9th, 2003, 9:31 pm
Contact:
Spifftastic! I can't wait to play with this feature.
Signature dropped due to use of img tag

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
Attachments
unitShadows1.png (52.63 KiB) Viewed 4394 times
unitShadows2.png (12.09 KiB) Viewed 4393 times
unitShadows3.png (14.72 KiB) Viewed 4394 times

Jetrel
Art Director
Posts: 7242
Joined: February 23rd, 2004, 3:36 am
Location: Midwest US
More images for a tutorial.
Attachments
unitShadows4.png (15.97 KiB) Viewed 4387 times
unitShadows5.png (12.31 KiB) Viewed 4386 times
unitShadows6.png (42.67 KiB) Viewed 4386 times

Viliam
Translator
Posts: 1341
Joined: January 30th, 2004, 11:07 am
Location: Bratislava, Slovakia
Contact:
Darth Fool wrote:Amongst the other changes that I am making, it will be possible to define the default colors in WML.
How about setting the team colors in user preferences? It could be useful for color-blind people... for each form of color-blindness there could be one recommended color scheme where colors look most different. It is not necessary to pick RGB values for each team (this would make UI too difficult), but selecting from a few pre-built color sets could be useful and easy to implement.

Darth Fool
Retired Developer
Posts: 2633
Joined: March 22nd, 2004, 11:22 pm
``````./TeamColorizer.pl colorswatch_200.png colorswatch-red.png