Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions util/colors.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ struct Color {
uint8_t r, g, b;
};

constexpr Color() = default;

explicit constexpr Color(uint8_t r, uint8_t g, uint8_t b)
: r_(r)
, g_(g)
, b_(b) {
}

constexpr Color()
: r_(0)
, g_(0)
, b_(0) {
}

constexpr Color(uint16_t rgb565)
: r_((rgb565 & 0xf800) >> 8)
, g_((rgb565 & 0x07e0) >> 3)
Expand All @@ -55,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_);
}

Expand Down Expand Up @@ -140,7 +136,9 @@ struct Color {
}

private:
uint8_t r_, g_, b_;
uint8_t r_{};
uint8_t g_{};
uint8_t b_{};
};

struct Colors {
Expand Down