ESPHome
2026.11.0-dev
Loading...
Searching...
No Matches
esphome
core
color.cpp
Go to the documentation of this file.
1
#include "
esphome/core/color.h
"
2
3
namespace
esphome
{
4
5
// C++20 constinit ensures compile-time initialization (stored in ROM)
6
constinit
const
Color
Color::BLACK
(0, 0, 0, 0);
7
constinit
const
Color
Color::WHITE
(255, 255, 255, 255);
8
9
Color
Color::gradient
(
const
Color
&to_color, uint8_t amnt)
const
{
10
return
Color
(
blend_channel
(this->
r
, to_color.
r
, amnt),
blend_channel
(this->
g
, to_color.
g
, amnt),
11
blend_channel
(this->
b
, to_color.
b
, amnt),
blend_channel
(this->
w
, to_color.
w
, amnt));
12
}
13
14
Color
Color::fade_to_white
(uint8_t amnt)
const
{
return
this->
gradient
(
Color::WHITE
, amnt); }
15
16
Color
Color::fade_to_black
(uint8_t amnt)
const
{
return
this->
gradient
(
Color::BLACK
, amnt); }
17
18
}
// namespace esphome
color.h
esphome
Definition
a01nyub.cpp:7
esphome::Color
Definition
color.h:26
esphome::Color::w
uint8_t w
Definition
color.h:42
esphome::Color::gradient
Color gradient(const Color &to_color, uint8_t amnt) const
Definition
color.cpp:9
esphome::Color::blend_channel
static uint8_t blend_channel(uint8_t from, uint8_t to, uint8_t amnt) ESPHOME_ALWAYS_INLINE
One channel of gradient(): from at amnt 0 to to at amnt 255.
Definition
color.h:180
esphome::Color::g
uint8_t g
Definition
color.h:34
esphome::Color::fade_to_white
Color fade_to_white(uint8_t amnt) const
Definition
color.cpp:14
esphome::Color::fade_to_black
Color fade_to_black(uint8_t amnt) const
Definition
color.cpp:16
esphome::Color::b
uint8_t b
Definition
color.h:38
esphome::Color::Color
constexpr Color() ESPHOME_ALWAYS_INLINE
Definition
color.h:55
esphome::Color::WHITE
static const Color WHITE
Definition
color.h:191
esphome::Color::r
uint8_t r
Definition
color.h:30
esphome::Color::BLACK
static const Color BLACK
Definition
color.h:190
Generated by
1.12.0