ESPHome  2024.11.0
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
esphome::Color Struct Reference

#include <color.h>

Public Member Functions

 Color () ESPHOME_ALWAYS_INLINE
 
 Color (uint8_t red, uint8_t green, uint8_t blue) ESPHOME_ALWAYS_INLINE
 
 Color (uint8_t red, uint8_t green, uint8_t blue, uint8_t white) ESPHOME_ALWAYS_INLINE
 
 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 10 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/4]

esphome::Color::Color ( )
inline

Definition at line 34 of file color.h.

◆ Color() [2/4]

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

Definition at line 35 of file color.h.

◆ Color() [3/4]

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

Definition at line 37 of file color.h.

◆ Color() [4/4]

esphome::Color::Color ( uint32_t  colorcode)
inlineexplicit

Definition at line 41 of file color.h.

Member Function Documentation

◆ darken()

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

Definition at line 166 of file color.h.

◆ fade_to_black()

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

Definition at line 163 of file color.h.

◆ fade_to_white()

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

Definition at line 162 of file color.h.

◆ gradient()

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

Definition at line 153 of file color.h.

◆ is_on()

bool esphome::Color::is_on ( )
inline

Definition at line 46 of file color.h.

◆ lighten()

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

Definition at line 165 of file color.h.

◆ operator!=() [1/2]

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

Definition at line 54 of file color.h.

◆ operator!=() [2/2]

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

Definition at line 57 of file color.h.

◆ operator*() [1/2]

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

Definition at line 61 of file color.h.

◆ operator*() [2/2]

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

Definition at line 75 of file color.h.

◆ operator*=() [1/2]

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

Definition at line 68 of file color.h.

◆ operator*=() [2/2]

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

Definition at line 79 of file color.h.

◆ operator+() [1/2]

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

Definition at line 86 of file color.h.

◆ operator+() [2/2]

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

Definition at line 111 of file color.h.

◆ operator+=() [1/2]

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

Definition at line 110 of file color.h.

◆ operator+=() [2/2]

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

Definition at line 112 of file color.h.

◆ operator-() [1/2]

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

Definition at line 113 of file color.h.

◆ operator-() [2/2]

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

Definition at line 138 of file color.h.

◆ operator-=() [1/2]

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

Definition at line 137 of file color.h.

◆ operator-=() [2/2]

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

Definition at line 141 of file color.h.

◆ operator==() [1/2]

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

Definition at line 48 of file color.h.

◆ operator==() [2/2]

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

Definition at line 51 of file color.h.

◆ operator[]()

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

Definition at line 60 of file color.h.

◆ operator~()

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

Definition at line 65 of file color.h.

◆ random_color()

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

Definition at line 142 of file color.h.

Field Documentation

◆ @146

union { ... }

◆ b

uint8_t esphome::Color::b

Definition at line 22 of file color.h.

◆ BLACK

const Color esphome::Color::BLACK
static

Definition at line 168 of file color.h.

◆ blue

uint8_t esphome::Color::blue

Definition at line 23 of file color.h.

◆ g

uint8_t esphome::Color::g

Definition at line 18 of file color.h.

◆ green

uint8_t esphome::Color::green

Definition at line 19 of file color.h.

◆ r

uint8_t esphome::Color::r

Definition at line 14 of file color.h.

◆ raw

uint8_t esphome::Color::raw[4]

Definition at line 30 of file color.h.

◆ raw_32

uint32_t esphome::Color::raw_32

Definition at line 31 of file color.h.

◆ red

uint8_t esphome::Color::red

Definition at line 15 of file color.h.

◆ w

uint8_t esphome::Color::w

Definition at line 26 of file color.h.

◆ white

uint8_t esphome::Color::white

Definition at line 27 of file color.h.

◆ WHITE

const Color esphome::Color::WHITE
static

Definition at line 169 of file color.h.


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