ESPHome 2025.7.2
Loading...
Searching...
No Matches
esphome::Color Struct Reference

#include <color.h>

Public Member Functions

constexpr Color () ESPHOME_ALWAYS_INLINE
 
constexpr Color (uint8_t red, uint8_t green, uint8_t blue) ESPHOME_ALWAYS_INLINE
 
constexpr Color (uint8_t red, uint8_t green, uint8_t blue, uint8_t white) ESPHOME_ALWAYS_INLINE
 
constexpr Color (uint32_t colorcode) ESPHOME_ALWAYS_INLINE
 
bool is_on () ESPHOME_ALWAYS_INLINE
 
bool operator== (const Color &rhs)
 
bool operator== (uint32_t colorcode)
 
bool operator!= (const Color &rhs)
 
bool operator!= (uint32_t colorcode)
 
uint8_t & operator[] (uint8_t x) ESPHOME_ALWAYS_INLINE
 
Color operator* (uint8_t scale) const ESPHOME_ALWAYS_INLINE
 
Color operator~ () const ESPHOME_ALWAYS_INLINE
 
Coloroperator*= (uint8_t scale) ESPHOME_ALWAYS_INLINE
 
Color operator* (const Color &scale) const ESPHOME_ALWAYS_INLINE
 
Coloroperator*= (const Color &scale) ESPHOME_ALWAYS_INLINE
 
Color operator+ (const Color &add) const ESPHOME_ALWAYS_INLINE
 
Coloroperator+= (const Color &add) ESPHOME_ALWAYS_INLINE
 
Color operator+ (uint8_t add) const ESPHOME_ALWAYS_INLINE
 
Coloroperator+= (uint8_t add) ESPHOME_ALWAYS_INLINE
 
Color operator- (const Color &subtract) const ESPHOME_ALWAYS_INLINE
 
Coloroperator-= (const Color &subtract) ESPHOME_ALWAYS_INLINE
 
Color operator- (uint8_t subtract) const ESPHOME_ALWAYS_INLINE
 
Coloroperator-= (uint8_t subtract) ESPHOME_ALWAYS_INLINE
 
Color gradient (const Color &to_color, uint8_t amnt)
 
Color fade_to_white (uint8_t amnt)
 
Color fade_to_black (uint8_t amnt)
 
Color lighten (uint8_t delta)
 
Color darken (uint8_t delta)
 

Static Public Member Functions

static Color random_color ()
 

Data Fields

union { 
 
   struct { 
 
      union { 
 
         uint8_t   r 
 
         uint8_t   red 
 
      }  
 
      union { 
 
         uint8_t   g 
 
         uint8_t   green 
 
      }  
 
      union { 
 
         uint8_t   b 
 
         uint8_t   blue 
 
      }  
 
      union { 
 
         uint8_t   w 
 
         uint8_t   white 
 
      }  
 
   }  
 
   uint8_t   raw [4] 
 
   uint32_t   raw_32 
 
};  
 

Static Public Attributes

static const Color BLACK
 
static const Color WHITE
 

Detailed Description

Definition at line 12 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/4]

esphome::Color::Color ( )
inlineconstexpr

Definition at line 36 of file color.h.

◆ Color() [2/4]

esphome::Color::Color ( uint8_t red,
uint8_t green,
uint8_t blue )
inlineconstexpr

Definition at line 37 of file color.h.

◆ Color() [3/4]

esphome::Color::Color ( uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t white )
inlineconstexpr

Definition at line 42 of file color.h.

◆ Color() [4/4]

esphome::Color::Color ( uint32_t colorcode)
inlineexplicitconstexpr

Definition at line 46 of file color.h.

Member Function Documentation

◆ darken()

Color esphome::Color::darken ( uint8_t delta)
inline

Definition at line 171 of file color.h.

◆ fade_to_black()

Color esphome::Color::fade_to_black ( uint8_t amnt)
inline

Definition at line 168 of file color.h.

◆ fade_to_white()

Color esphome::Color::fade_to_white ( uint8_t amnt)
inline

Definition at line 167 of file color.h.

◆ gradient()

Color esphome::Color::gradient ( const Color & to_color,
uint8_t amnt )
inline

Definition at line 158 of file color.h.

◆ is_on()

bool esphome::Color::is_on ( )
inline

Definition at line 51 of file color.h.

◆ lighten()

Color esphome::Color::lighten ( uint8_t delta)
inline

Definition at line 170 of file color.h.

◆ operator!=() [1/2]

bool esphome::Color::operator!= ( const Color & rhs)
inline

Definition at line 59 of file color.h.

◆ operator!=() [2/2]

bool esphome::Color::operator!= ( uint32_t colorcode)
inline

Definition at line 62 of file color.h.

◆ operator*() [1/2]

Color esphome::Color::operator* ( const Color & scale) const
inline

Definition at line 80 of file color.h.

◆ operator*() [2/2]

Color esphome::Color::operator* ( uint8_t scale) const
inline

Definition at line 66 of file color.h.

◆ operator*=() [1/2]

Color & esphome::Color::operator*= ( const Color & scale)
inline

Definition at line 84 of file color.h.

◆ operator*=() [2/2]

Color & esphome::Color::operator*= ( uint8_t scale)
inline

Definition at line 73 of file color.h.

◆ operator+() [1/2]

Color esphome::Color::operator+ ( const Color & add) const
inline

Definition at line 91 of file color.h.

◆ operator+() [2/2]

Color esphome::Color::operator+ ( uint8_t add) const
inline

Definition at line 116 of file color.h.

◆ operator+=() [1/2]

Color & esphome::Color::operator+= ( const Color & add)
inline

Definition at line 115 of file color.h.

◆ operator+=() [2/2]

Color & esphome::Color::operator+= ( uint8_t add)
inline

Definition at line 117 of file color.h.

◆ operator-() [1/2]

Color esphome::Color::operator- ( const Color & subtract) const
inline

Definition at line 118 of file color.h.

◆ operator-() [2/2]

Color esphome::Color::operator- ( uint8_t subtract) const
inline

Definition at line 143 of file color.h.

◆ operator-=() [1/2]

Color & esphome::Color::operator-= ( const Color & subtract)
inline

Definition at line 142 of file color.h.

◆ operator-=() [2/2]

Color & esphome::Color::operator-= ( uint8_t subtract)
inline

Definition at line 146 of file color.h.

◆ operator==() [1/2]

bool esphome::Color::operator== ( const Color & rhs)
inline

Definition at line 53 of file color.h.

◆ operator==() [2/2]

bool esphome::Color::operator== ( uint32_t colorcode)
inline

Definition at line 56 of file color.h.

◆ operator[]()

uint8_t & esphome::Color::operator[] ( uint8_t x)
inline

Definition at line 65 of file color.h.

◆ operator~()

Color esphome::Color::operator~ ( ) const
inline

Definition at line 70 of file color.h.

◆ random_color()

static Color esphome::Color::random_color ( )
inlinestatic

Definition at line 147 of file color.h.

Field Documentation

◆ [union]

union { ... } esphome::Color

◆ b

uint8_t esphome::Color::b

Definition at line 24 of file color.h.

◆ BLACK

const Color esphome::Color::BLACK
staticconstinit

Definition at line 173 of file color.h.

◆ blue

uint8_t esphome::Color::blue

Definition at line 25 of file color.h.

◆ g

uint8_t esphome::Color::g

Definition at line 20 of file color.h.

◆ green

uint8_t esphome::Color::green

Definition at line 21 of file color.h.

◆ r

uint8_t esphome::Color::r

Definition at line 16 of file color.h.

◆ raw

uint8_t esphome::Color::raw[4]

Definition at line 32 of file color.h.

◆ raw_32

uint32_t esphome::Color::raw_32

Definition at line 33 of file color.h.

◆ red

uint8_t esphome::Color::red

Definition at line 17 of file color.h.

◆ w

uint8_t esphome::Color::w

Definition at line 28 of file color.h.

◆ WHITE

const Color esphome::Color::WHITE
staticconstinit

Definition at line 174 of file color.h.

◆ white

uint8_t esphome::Color::white

Definition at line 29 of file color.h.


The documentation for this struct was generated from the following files: