From 34df7a6072f27b3dc721846b8376dc75a9a8ab3b Mon Sep 17 00:00:00 2001 From: NP v/d Spek Date: Tue, 9 Aug 2022 02:29:41 +0200 Subject: [PATCH] add gradient color (#3687) --- esphome/core/color.h | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/core/color.h b/esphome/core/color.h index c9ca3bcfc3..4e7733ca85 100644 --- a/esphome/core/color.h +++ b/esphome/core/color.h @@ -141,6 +141,7 @@ struct Color { } Color fade_to_white(uint8_t amnt) { return Color(255, 255, 255, 255) - (*this * amnt); } Color fade_to_black(uint8_t amnt) { return *this * amnt; } + Color gradient(const Color &to_color, uint8_t amnt) { return (*this * amnt) + (to_color * (255 - amnt)); } Color lighten(uint8_t delta) { return *this + delta; } Color darken(uint8_t delta) { return *this - delta; }