From 519df37a0c6beeb22725516a4f930986efaae82f Mon Sep 17 00:00:00 2001 From: audiobird Date: Fri, 22 Aug 2025 16:56:42 -0700 Subject: [PATCH 1/3] colors: default initialize r,g,b. Add default constructor, remove default arguments --- util/colors.hh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/colors.hh b/util/colors.hh index 3d955a7..3667c08 100644 --- a/util/colors.hh +++ b/util/colors.hh @@ -27,7 +27,9 @@ struct Color { uint8_t r, g, b; }; - explicit constexpr Color(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0) + constexpr Color() = default; + + explicit constexpr Color(uint8_t r, uint8_t g, uint8_t b) : r_(r) , g_(g) , b_(b) { @@ -134,7 +136,9 @@ struct Color { } private: - uint8_t r_, g_, b_; + uint8_t r_{}; + uint8_t g_{}; + uint8_t b_{}; }; struct Colors { From 630a8f9d46cf27753d4f98d84b1014bef8cab701 Mon Sep 17 00:00:00 2001 From: audiobird Date: Sat, 24 Jan 2026 10:19:26 -0800 Subject: [PATCH 2/3] constexpr color operations --- util/colors.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/colors.hh b/util/colors.hh index 3667c08..f342251 100644 --- a/util/colors.hh +++ b/util/colors.hh @@ -51,15 +51,15 @@ struct Color { return b_; } - const Color operator+(Color const that) const { + constexpr Color operator+(Color const that) const { return Color(builtin_add_u8(r_, that.r_), builtin_add_u8(g_, that.g_), builtin_add_u8(b_, that.b_)); } - const Color operator*(float phase) const { + constexpr Color operator*(float phase) const { return Color{0, 0, 0}.blend(*this, phase); } - bool operator==(Color const &other) const { + constexpr bool operator==(Color const &other) const { return (r_ == other.r_ && g_ == other.g_ && b_ == other.b_); } From de15b058850f141f19ddd8d47bf99d454dc9e7ab Mon Sep 17 00:00:00 2001 From: audiobird Date: Sat, 24 Jan 2026 10:22:52 -0800 Subject: [PATCH 3/3] remove constructor --- util/colors.hh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/util/colors.hh b/util/colors.hh index 6336e3d..f342251 100644 --- a/util/colors.hh +++ b/util/colors.hh @@ -35,12 +35,6 @@ struct Color { , b_(b) { } - constexpr Color() - : r_(0) - , g_(0) - , b_(0) { - } - constexpr Color(uint16_t rgb565) : r_((rgb565 & 0xf800) >> 8) , g_((rgb565 & 0x07e0) >> 3)