TeamColoring

From The Battle for Wesnoth Wiki

If you're an artist, or if you want to use a Wesnoth sprite as your avatar in the forums, or for whatever reason you want to produce a team-colored copy of a Wesnoth sprite without actually running Wesnoth (and probably having to cut the sprite out of a background), there are two easy tools to accomplish this:

  • TeamColorizer - This is a Python script included with Wesnoth that does an inaccurate teamcoloring: it uses a slightly different algorithm than the one used in-game. However, it allows you to use any color that you want, even colors that aren't normal team colors. You just need to do a bit of trickery.
  • wesnoth-tc - This is a C++ program, written by Shadowmaster from the forums. It even has a GUI written for Macs. It uses the same algorithm as the Wesnoth engine.

TeamColorizer

The TeamColorizer included with Wesnoth is at data/tools/unit_tree/TeamColorizer. Internally, it's used to produce the red sprites found on http://units.wesnoth.org. However, you can use it to color any image red. It's a command-line program, so first you'll need to open up a command line (either Start->Run and then type "cmd" in Windows, or use Terminal on a Mac; if you run something else you should know how to do this already). Next, you need to find two things: Python, and the TeamColorizer. You don't have to do this in the shell. Python is likely to be at

C:\Python<#>\Python.exe

or something like that, where <#> is the version, and will be something like '25' for 2.5, '26' for 2.6, etc. You actually don't need this step on a Mac. Next, you have to find the TeamColorizer, and this one you have to do in the shell, by typing

cd <directory>

and then either 'ls' or 'dir' depending on whether you're on Windows ('dir') or on something else. The directory you want is data/tools/unit_tree relative to the Wesnoth data directory. Once you're there, type

python TeamColorizer <input_image> <output_image>

where <input_image> and <output_image> are the full paths to the input image and desired output image, respectively. If you don't want to worry about where the images are, you can just copy the image you want to use into the same directory as the TeamColorizer for simplicity. Note that the output image will also appear in the same directory as the TeamColorizer unless you give it a different path. If you want, you can copy the whole TeamColorizer somewhere else for convenience. A quick example of what you might do:

C:\> cd C:\Progra~1\Wesnoth\data\tools\unit_tree
C:\Program Files\Wesnoth\data\tools\unit_tree> C:\Python25\Python.exe TeamColorizer C:\my_image.png out.png

on Windows, or

cd /usr/local/share/wesnoth/data/tools/unit_tree
./TeamColorizer ~/Desktop/in.png ~/Desktop/out.png

on a Mac (although that Wesnoth path might not be the same as yours...).

Note: these are pretty bad and technical instructions... especially the Windows side. Please revise them if you've got a better way of explaining things. Maybe you could just create a shortcut with the arguments in it in Windows and that would be simpler? (In fact, I'm not even sure if the Windows instructions are correct!)

So now you have a red copy of your image. Hooray! What about other colors? There's currently a patch being considered that will make this bit a little easier (this editor will be honest and admit that eir the one that submitted the patch) but for now, you have to edit the TeamColorizer file. Open it with wordpad, textmate, or whatever text editor you normally use. Look near the top for a place where it says:

team_red = 255
team_green = 0
team_blue = 0

or something like that. Simply change the red, green, and blue values to your desired color and run the script again. For reference, the Wesnoth team colors are listed in data/core/team-colors.cfg, although because of the difference in algorithm, using the "average color" listed in that file may produce more washed-out variants; try using the "flag color", or some combination of the two.

wesnoth-tc

If you want to use wesnoth-tc, read up on it on its forum thread. The thread has information on usage and a link to download the source, as well as information on the Mac GUI. Feel free to post more instructions here if you use it and feel like sharing any insights you gain.

This page was last edited on 8 May 2023, at 04:57.