The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Private Attributes | List of all members
color_range Class Reference

A color range definition is made of four reference RGB colors, used for calculating conversions from a source/key palette. More...

#include <color_range.hpp>

Public Member Functions

 color_range (color_t mid, color_t max={255, 255, 255}, color_t min={0, 0, 0}, color_t rep={128, 128, 128})
 Constructor, which expects four reference RGB colors. More...
 
 color_range (const std::vector< color_t > &v)
 Constructor, which expects four reference RGB colors. More...
 
 color_range ()
 Default constructor. More...
 
color_t mid () const
 Average color shade. More...
 
color_t max () const
 Maximum color shade. More...
 
color_t min () const
 Minimum color shade. More...
 
color_t rep () const
 High-contrast shade, intended for the minimap markers. More...
 
bool operator== (const color_range &b) const
 
bool operator< (const color_range &b) const
 
std::string debug () const
 Return a string describing the color range for debug output. More...
 

Private Attributes

color_t mid_
 
color_t max_
 
color_t min_
 
color_t rep_
 

Detailed Description

A color range definition is made of four reference RGB colors, used for calculating conversions from a source/key palette.

1) The average shade of a unit's team-color portions (default: gray #808080) 2) The maximum highlight shade of a unit's team-color portions (default: white) 3) The minimum shadow shade of a unit's team-color portions (default: black) 4) A plain high-contrast color, used for the markers on the mini-map (default: same as the provided average shade, or gray #808080)

The first three reference colors are used for converting a source palette with the external recolor_range() method.

Definition at line 48 of file color_range.hpp.

Constructor & Destructor Documentation

◆ color_range() [1/3]

color_range::color_range ( color_t  mid,
color_t  max = {255, 255, 255},
color_t  min = {0, 0, 0},
color_t  rep = {128, 128, 128} 
)
inline

Constructor, which expects four reference RGB colors.

Parameters
midAverage color shade.
maxMaximum (highlight) color shade
minMinimum color shade
repHigh-contrast reference color

Definition at line 58 of file color_range.hpp.

◆ color_range() [2/3]

color_range::color_range ( const std::vector< color_t > &  v)
inline

Constructor, which expects four reference RGB colors.

Parameters
vSTL vector with the four reference colors in order.

Definition at line 69 of file color_range.hpp.

◆ color_range() [3/3]

color_range::color_range ( )
inline

Default constructor.

Definition at line 77 of file color_range.hpp.

Member Function Documentation

◆ debug()

std::string color_range::debug ( ) const

Return a string describing the color range for debug output.

Definition at line 115 of file color_range.cpp.

References max_, mid_, min_, rep_, and color_t::to_hex_string().

◆ max()

color_t color_range::max ( ) const
inline

Maximum color shade.

Definition at line 88 of file color_range.hpp.

References max_.

Referenced by recolor_range().

◆ mid()

color_t color_range::mid ( ) const
inline

Average color shade.

Definition at line 85 of file color_range.hpp.

References mid_.

Referenced by display_chat_manager::add_chat_message(), team::get_side_color(), team::get_side_highlight_pango(), and recolor_range().

◆ min()

color_t color_range::min ( ) const
inline

Minimum color shade.

Definition at line 91 of file color_range.hpp.

References min_.

Referenced by recolor_range().

◆ operator<()

bool color_range::operator< ( const color_range b) const
inline

Definition at line 101 of file color_range.hpp.

References b, max_, mid_, min_, rep_, and color_t::to_rgba_bytes().

◆ operator==()

bool color_range::operator== ( const color_range b) const
inline

Definition at line 96 of file color_range.hpp.

References b, max_, mid_, min_, and rep_.

◆ rep()

color_t color_range::rep ( ) const
inline

High-contrast shade, intended for the minimap markers.

Definition at line 94 of file color_range.hpp.

References rep_.

Referenced by display::draw_minimap_units(), team::get_minimap_color(), and image::prep_minimap_for_rendering().

Member Data Documentation

◆ max_

color_t color_range::max_
private

Definition at line 114 of file color_range.hpp.

Referenced by debug(), max(), operator<(), and operator==().

◆ mid_

color_t color_range::mid_
private

Definition at line 114 of file color_range.hpp.

Referenced by debug(), mid(), operator<(), and operator==().

◆ min_

color_t color_range::min_
private

Definition at line 114 of file color_range.hpp.

Referenced by debug(), min(), operator<(), and operator==().

◆ rep_

color_t color_range::rep_
private

Definition at line 114 of file color_range.hpp.

Referenced by debug(), operator<(), operator==(), and rep().


The documentation for this class was generated from the following files: