Move apply_alpha functionality into rgba

This commit is contained in:
patrick96
2019-10-28 00:40:59 +01:00
committed by Patrick Ziegler
parent eeab4f0d45
commit 413c911cd1
4 changed files with 28 additions and 8 deletions

View File

@ -30,7 +30,7 @@ static string normalize_hex(string hex) {
}
if (hex.length() == 3) {
// RGB -> ARGB
// RGB -> FRGB
hex.insert(0, 1, 'f');
}
@ -134,6 +134,15 @@ bool rgba::has_color() const {
return m_type != NONE;
}
/**
* Replaces the current alpha channel with the alpha channel of the other color
*
* Useful for ALPHA_ONLY colors
*/
void rgba::apply_alpha(rgba other) {
m_value = (m_value & 0x00FFFFFF) | (other.a_int() << 24);
}
string color_util::simplify_hex(string hex) {
// convert #ffrrggbb to #rrggbb
if (hex.length() == 9 && std::toupper(hex[1]) == 'F' && std::toupper(hex[2]) == 'F') {