Dfool of many colors
Moderator: Forum Moderators
Let's see...Jetryl wrote:Yobbo, do you want to figure this out, or shall I commence to ciphering?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?)
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
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...
-
- Retired Developer
- Posts: 2633
- Joined: March 22nd, 2004, 11:22 pm
- Location: An Earl's Roadstead
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:
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.
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
}
"you can already do that with WML"
Fight Creeeping Biggerism!
http://www.wesnoth.org/forum/viewtopic. ... 760#131760
http://www.wesnoth.org/forum/viewtopic. ... 1358#11358
Yeah, using the sum/average of r/g/b like you are is better than what I said .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.
I like the idea of the Inverted Psychadelic Rainbow team... please leave this possibility in .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.
-
- Retired Developer
- Posts: 2633
- Joined: March 22nd, 2004, 11:22 pm
- Location: An Earl's Roadstead
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...
"you can already do that with WML"
Fight Creeeping Biggerism!
http://www.wesnoth.org/forum/viewtopic. ... 760#131760
http://www.wesnoth.org/forum/viewtopic. ... 1358#11358
- 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
-> What i might be working on
Attempting Lucidity
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
And I hate stupid people.
The World of Orbivm
Ahem:turin wrote:So, uh... which pallette of magenta colors should we use to get tcolor done correctly?
http://www.wesnoth.org/wiki/Team_Color_Shifting
The one linked in there.
-
- Posts: 719
- Joined: December 9th, 2003, 9:31 pm
- Contact:
- Viliam
- Translator
- Posts: 1341
- Joined: January 30th, 2004, 11:07 am
- Location: Bratislava, Slovakia
- Contact:
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 wrote:Amongst the other changes that I am making, it will be possible to define the default colors in WML.
-
- Retired Developer
- Posts: 2633
- Joined: March 22nd, 2004, 11:22 pm
- Location: An Earl's Roadstead
I provide attached a new tool for art developers and possibly use on the automated unit web pages. The tool is a perl script that uses the ImageMagic convert program to take an existing file that uses the magenta coloring scheme and convert it into a very close approximation of what wesnoth will do using the default team 1's coloring scheme (red). The tool is used like the following:
I attach what happens to the magenta colorswatch. Note that I don't think that this is quite the intention of Jetryl for what the colorswatch should do. The "new attachment" is what happens if I set the middle color(236,0,140) in the swatch to be the team color. I have commented out the line in the perl script that makes the change, however, we might want to consider changing the macro definition in utils.cfg to fix this.
Code: Select all
./TeamColorizer.pl colorswatch_200.png colorswatch-red.png
- Attachments
-
- colorswatch-new-red.png (350 Bytes) Viewed 5709 times
-
- TeamColorizer.pl.gz
- (790 Bytes) Downloaded 529 times
-
- colorswatch-red.png (326 Bytes) Viewed 5709 times
"you can already do that with WML"
Fight Creeeping Biggerism!
http://www.wesnoth.org/forum/viewtopic. ... 760#131760
http://www.wesnoth.org/forum/viewtopic. ... 1358#11358