From 63290a265ccfe5c75c80842bc2f91e4915f541a1 Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Thu, 25 Aug 2022 03:41:52 +0200 Subject: [PATCH] add color compare operator's (#3730) --- esphome/core/color.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/esphome/core/color.h b/esphome/core/color.h index 7596eeb0cf..7062a2a8c8 100644 --- a/esphome/core/color.h +++ b/esphome/core/color.h @@ -44,6 +44,20 @@ struct Color { w((colorcode >> 24) & 0xFF) {} inline bool is_on() ALWAYS_INLINE { return this->raw_32 != 0; } + + inline bool operator==(const Color &rhs) { // NOLINT + return this->raw_32 == rhs.raw_32; + } + inline bool operator==(uint32_t colorcode) { // NOLINT + return this->raw_32 == colorcode; + } + inline bool operator!=(const Color &rhs) { // NOLINT + return this->raw_32 != rhs.raw_32; + } + inline bool operator!=(uint32_t colorcode) { // NOLINT + return this->raw_32 != colorcode; + } + inline Color &operator=(const Color &rhs) ALWAYS_INLINE { // NOLINT this->r = rhs.r; this->g = rhs.g;