mirror of
https://github.com/polybar/polybar.git
synced 2026-03-18 06:07:07 +00:00
Move apply_alpha functionality into rgba
This commit is contained in:
committed by
Patrick Ziegler
parent
eeab4f0d45
commit
413c911cd1
@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user