#include <color.hpp>
Public Member Functions | |
color_t () | |
color_t (uint8_t r_val, uint8_t g_val, uint8_t b_val, uint8_t a_val=ALPHA_OPAQUE) | |
color_t (const SDL_Color &c) | |
std::string | to_hex_string () const |
Returns the stored color in rrggbb hex format. More... | |
uint32_t | to_rgba_bytes () const |
Returns the stored color as a uint32_t, in RGBA format. More... | |
uint32_t | to_argb_bytes () const |
Returns the stored color as a uint32_t, an ARGB format. More... | |
std::string | to_rgba_string () const |
Returns the stored color as an "R,G,B,A" string. More... | |
std::string | to_rgb_string () const |
Returns the stored color as an "R,G,B" string. More... | |
SDL_Color | to_sdl () const |
Returns the stored color as an color_t object. More... | |
bool | null () const |
bool | operator== (const color_t &c) const |
bool | operator!= (const color_t &c) const |
color_t | blend_add (const color_t &c) const |
color_t | blend_lighten (const color_t &c) const |
color_t | inverse () const |
Static Public Member Functions | |
static color_t | from_rgba_string (const std::string &c) |
Creates a new color_t object from a string variable in "R,G,B,A" format. More... | |
static color_t | from_rgb_string (const std::string &c) |
Creates a new opaque color_t object from a string variable in "R,G,B" format. More... | |
static color_t | from_hex_string (const std::string &c) |
Creates a new color_t object from a string variable in hex format. More... | |
static color_t | from_rgba_bytes (uint32_t c) |
Creates a new color_t object from a uint32_t variable. More... | |
static color_t | from_argb_bytes (uint32_t c) |
Creates a new color_t object from a uint32_t variable. More... | |
static color_t | null_color () |
Definition of a 'null' color - fully transparent black. More... | |
Public Attributes | |
uint8_t | r |
Red value. More... | |
uint8_t | g |
Green value. More... | |
uint8_t | b |
Blue value. More... | |
uint8_t | a |
Alpha value. More... | |
|
inline |
Definition at line 59 of file color.hpp.
References c, color_t(), from_argb_bytes(), from_hex_string(), from_rgb_string(), from_rgba_bytes(), from_rgba_string(), and to_hex_string().
|
static |
Creates a new color_t object from a uint32_t variable.
c | A uint32_t variable, in ARGB format. |
Definition at line 87 of file color.cpp.
References c, SDL_ALPHA_BITSHIFT, SDL_ALPHA_MASK, SDL_BLUE_BITSHIFT, SDL_BLUE_MASK, SDL_GREEN_BITSHIFT, SDL_GREEN_MASK, SDL_RED_BITSHIFT, and SDL_RED_MASK.
Referenced by color_t(), and recolor_image().
|
static |
Creates a new color_t object from a string variable in hex format.
c | A string variable, in rrggbb hex format. |
std::invalid_argument | if the string is not correctly formatted |
Definition at line 61 of file color.cpp.
References ALPHA_OPAQUE.
Referenced by game_config::add_color_info(), game_config::color_info(), color_t(), gui2::styled_widget::get_link_color(), game_config::load_config(), help::string_to_color(), and game_config::tc_info().
|
static |
Creates a new opaque color_t object from a string variable in "R,G,B" format.
An empty string results in white. Otherwise, omitting components is an error.
c | A string variable, in "R,G,B" format. |
std::invalid_argument | if the string is not correctly formatted |
Definition at line 41 of file color.cpp.
References ALPHA_OPAQUE, null_color(), and utils::split().
Referenced by color_t(), frame_builder::frame_builder(), game_lua_kernel::intf_float_label(), game_lua_kernel::intf_print(), theme::label::label(), terrain_label::read(), and theme::status_item::status_item().
|
static |
Creates a new color_t object from a uint32_t variable.
c | A uint32_t variable, in RGBA format. |
Definition at line 77 of file color.cpp.
References c, RGBA_ALPHA_BITSHIFT, RGBA_ALPHA_MASK, RGBA_BLUE_BITSHIFT, RGBA_BLUE_MASK, RGBA_GREEN_BITSHIFT, RGBA_GREEN_MASK, RGBA_RED_BITSHIFT, and RGBA_RED_MASK.
Referenced by color_t().
|
static |
Creates a new color_t object from a string variable in "R,G,B,A" format.
An empty string results in white. Otherwise, omitting components other than alpha is an error.
c | A string variable, in "R,G,B,A" format. |
std::invalid_argument | if the string is not correctly formatted |
Definition at line 20 of file color.cpp.
References ALPHA_OPAQUE, null_color(), and utils::split().
Referenced by color_t(), gui2::typed_formula< bool >::convert(), gui2::decode_color(), and terrain_label::read().
|
inline |
|
inline |
Definition at line 188 of file color.hpp.
References null_color().
Referenced by gui2::rectangle_shape::draw(), gui2::round_rectangle_shape::draw(), and gui2::circle_shape::draw().
|
inlinestatic |
Definition of a 'null' color - fully transparent black.
Definition at line 236 of file color.hpp.
Referenced by from_rgb_string(), from_rgba_string(), and null().
|
inline |
|
inline |
|
inline |
Returns the stored color as a uint32_t, an ARGB format.
Definition at line 145 of file color.hpp.
References a, b, g, r, SDL_ALPHA_BITSHIFT, SDL_BLUE_BITSHIFT, SDL_GREEN_BITSHIFT, SDL_RED_BITSHIFT, to_rgb_string(), to_rgba_string(), and to_sdl().
Referenced by display::draw_minimap_units().
std::string color_t::to_hex_string | ( | ) | const |
Returns the stored color in rrggbb hex format.
Definition at line 97 of file color.cpp.
Referenced by attack_info(), color_t(), color_range::debug(), font::format_as_link(), team::get_side_highlight_pango(), help::unit_topic_generator::operator()(), and font::span_color().
std::string color_t::to_rgb_string | ( | ) | const |
Returns the stored color as an "R,G,B" string.
Definition at line 122 of file color.cpp.
Referenced by to_argb_bytes(), and terrain_label::write().
|
inline |
Returns the stored color as a uint32_t, in RGBA format.
Definition at line 131 of file color.hpp.
References a, b, g, r, RGBA_ALPHA_BITSHIFT, RGBA_BLUE_BITSHIFT, RGBA_GREEN_BITSHIFT, and RGBA_RED_BITSHIFT.
Referenced by color_range::operator<().
std::string color_t::to_rgba_string | ( | ) | const |
Returns the stored color as an "R,G,B,A" string.
Definition at line 110 of file color.cpp.
Referenced by gui2::dialogs::attack_predictions::draw_hp_graph(), and to_argb_bytes().
SDL_Color color_t::to_sdl | ( | ) | const |
Returns the stored color as an color_t object.
Definition at line 2288 of file utils.cpp.
Referenced by font::text_surface::get_surfaces(), and to_argb_bytes().
uint8_t color_t::a |
Alpha value.
Definition at line 186 of file color.hpp.
Referenced by blend_add(), blend_lighten(), draw_centered_on_background(), gui::textbox::draw_contents(), sdl::draw_rectangle(), gui::menu::style::draw_row_bg(), sdl::fill_rectangle(), luaW_pushsinglecolor(), image::adjust_alpha_modification::operator()(), image::adjust_channels_modification::operator()(), operator<<(), operator==(), font::pango_text::render(), font::floating_label::set_bg_color(), to_argb_bytes(), to_rgba_bytes(), to_rgba_string(), and gui2::styled_widget::update_canvas().
uint8_t color_t::b |
Blue value.
Definition at line 183 of file color.hpp.
Referenced by blend_add(), blend_lighten(), blend_surface(), font::floating_label::create_surface(), unit_drawer::draw_bar(), draw_centered_on_background(), draw_label(), sdl::draw_rectangle(), gui2::dialogs::editor_edit_label::editor_edit_label(), sdl::fill_rectangle(), image::getMinimap(), inverse(), luaW_pushsinglecolor(), image::adjust_alpha_modification::operator()(), image::adjust_channels_modification::operator()(), operator<<(), operator==(), recolor_range(), font::pango_text::render(), to_argb_bytes(), to_hex_string(), to_rgb_string(), to_rgba_bytes(), to_rgba_string(), and gui2::styled_widget::update_canvas().
uint8_t color_t::g |
Green value.
Definition at line 180 of file color.hpp.
Referenced by blend_add(), blend_lighten(), blend_surface(), font::floating_label::create_surface(), unit_drawer::draw_bar(), draw_centered_on_background(), draw_label(), sdl::draw_rectangle(), gui2::dialogs::editor_edit_label::editor_edit_label(), sdl::fill_rectangle(), image::getMinimap(), luaW_pushsinglecolor(), image::adjust_alpha_modification::operator()(), image::adjust_channels_modification::operator()(), operator<<(), operator==(), recolor_range(), font::pango_text::render(), to_argb_bytes(), to_hex_string(), to_rgb_string(), to_rgba_bytes(), to_rgba_string(), and gui2::styled_widget::update_canvas().
uint8_t color_t::r |
Red value.
Definition at line 177 of file color.hpp.
Referenced by blend_add(), blend_lighten(), blend_surface(), font::floating_label::create_surface(), unit_drawer::draw_bar(), draw_centered_on_background(), draw_label(), sdl::draw_rectangle(), gui2::dialogs::editor_edit_label::editor_edit_label(), sdl::fill_rectangle(), image::getMinimap(), hp_color_impl(), inverse(), luaW_pushsinglecolor(), image::adjust_alpha_modification::operator()(), image::adjust_channels_modification::operator()(), operator<<(), operator==(), recolor_range(), font::pango_text::render(), to_argb_bytes(), to_hex_string(), to_rgb_string(), to_rgba_bytes(), to_rgba_string(), and gui2::styled_widget::update_canvas().