Skip to content

Commit

Permalink
feat(color): added equality operators (#102)
Browse files Browse the repository at this point in the history
* Added equality and inequality operators for espp::Rgb and espp::Hsv
  • Loading branch information
finger563 authored Aug 4, 2023
1 parent f77aafa commit f9b056c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions components/color/include/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ class Hsv {
*/
Rgb rgb() const;
};

// equality operators
[[maybe_unused]] static bool operator==(const Rgb &lhs, const Rgb &rhs) {
return lhs.r == rhs.r && lhs.g == rhs.g && lhs.b == rhs.b;
}

[[maybe_unused]] static bool operator==(const Hsv &lhs, const Hsv &rhs) {
return lhs.h == rhs.h && lhs.s == rhs.s && lhs.v == rhs.v;
}

// inequality operators
[[maybe_unused]] static bool operator!=(const Rgb &lhs, const Rgb &rhs) { return !(lhs == rhs); }

[[maybe_unused]] static bool operator!=(const Hsv &lhs, const Hsv &rhs) { return !(lhs == rhs); }
} // namespace espp

#include "format.hpp"
Expand Down

0 comments on commit f9b056c

Please sign in to comment.