The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
color_range.cpp File Reference

Generate ranges of colors, and color palettes. More...

#include "color_range.hpp"
#include "game_config.hpp"
#include "map/map.hpp"
#include "serialization/string_utils.hpp"
#include "util.hpp"
#include <iomanip>
Include dependency graph for color_range.cpp:

Go to the source code of this file.

Functions

std::map< Uint32, Uint32 > recolor_range (const color_range &new_range, const std::vector< Uint32 > &old_rgb)
 Converts a source palette using the specified color_range object. More...
 
bool string2rgb (const std::string &s, std::vector< Uint32 > &result)
 
std::vector< Uint32 > palette (color_range cr)
 Creates a reference color palette from a color range. More...
 
std::string rgb2highlight (Uint32 rgb)
 Converts a color value to WML text markup syntax for highlighting. More...
 
std::string rgb2highlight_pango (Uint32 rgb)
 Converts a color value to WML text markup syntax for highlighting. More...
 

Detailed Description

Generate ranges of colors, and color palettes.

Used e.g. to color HP, XP.

Definition in file color_range.cpp.

Function Documentation

std::vector<Uint32> palette ( color_range  cr)

Creates a reference color palette from a color range.

Definition at line 130 of file color_range.cpp.

References c, i, and recolor_range().

Referenced by game_config::add_color_info().

std::map<Uint32, Uint32> recolor_range ( const color_range new_rgb,
const std::vector< Uint32 > &  old_rgb 
)

Converts a source palette using the specified color_range object.

This holds the main interface for range-based team coloring. The output is used with the recolor_image() method to do the actual recoloring.

Parameters
new_rgbSpecifies parameters for the conversion.
old_rgbSource palette.
Returns
A STL map of colors, with the keys being source palette elements, and the values are the result of applying the color range conversion on it.

Definition at line 30 of file color_range.cpp.

References color_range::max(), color_range::mid(), and color_range::min().

Referenced by BOOST_AUTO_TEST_CASE(), and palette().

std::string rgb2highlight ( Uint32  rgb)

Converts a color value to WML text markup syntax for highlighting.

For example, 0x00CC00CC becomes "<204,0,204>".

Definition at line 158 of file color_range.cpp.

References h.

Referenced by mp::get_color_string(), and team::get_side_highlight().

std::string rgb2highlight_pango ( Uint32  rgb)

Converts a color value to WML text markup syntax for highlighting.

For example, 0x00CC00CC becomes "#CC00CC".

Definition at line 168 of file color_range.cpp.

References h.

Referenced by team::get_side_highlight_pango().

bool string2rgb ( const std::string s,
std::vector< Uint32 > &  result 
)