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

#include <color.h>

Public Member Functions

 Color () ALWAYS_INLINE
 
 Color (uint8_t red, uint8_t green, uint8_t blue) ALWAYS_INLINE
 
 Color (uint8_t red, uint8_t green, uint8_t blue, uint8_t white) ALWAYS_INLINE
 
 Color (uint32_t colorcode) ALWAYS_INLINE
 
bool is_on () 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) ALWAYS_INLINE
 
Color operator* (uint8_t scale) const ALWAYS_INLINE
 
Coloroperator*= (uint8_t scale) ALWAYS_INLINE
 
Color operator* (const Color &scale) const ALWAYS_INLINE
 
Coloroperator*= (const Color &scale) ALWAYS_INLINE
 
Color operator+ (const Color &add) const ALWAYS_INLINE
 
Coloroperator+= (const Color &add) ALWAYS_INLINE
 
Color operator+ (uint8_t add) const ALWAYS_INLINE
 
Coloroperator+= (uint8_t add) ALWAYS_INLINE
 
Color operator- (const Color &subtract) const ALWAYS_INLINE
 
Coloroperator-= (const Color &subtract) ALWAYS_INLINE
 
Color operator- (uint8_t subtract) const ALWAYS_INLINE
 
Coloroperator-= (uint8_t subtract) 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 155 of file color.h.

◆ fade_to_black()

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

Definition at line 152 of file color.h.

◆ fade_to_white()

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

Definition at line 151 of file color.h.

◆ gradient()

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

Definition at line 142 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 154 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 72 of file color.h.

◆ operator*=() [1/2]

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

Definition at line 65 of file color.h.

◆ operator*=() [2/2]

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

Definition at line 76 of file color.h.

◆ operator+() [1/2]

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

Definition at line 83 of file color.h.

◆ operator+() [2/2]

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

Definition at line 104 of file color.h.

◆ operator+=() [1/2]

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

Definition at line 103 of file color.h.

◆ operator+=() [2/2]

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

Definition at line 105 of file color.h.

◆ operator-() [1/2]

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

Definition at line 106 of file color.h.

◆ operator-() [2/2]

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

Definition at line 127 of file color.h.

◆ operator-=() [1/2]

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

Definition at line 126 of file color.h.

◆ operator-=() [2/2]

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

Definition at line 130 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.

◆ random_color()

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

Definition at line 131 of file color.h.

Field Documentation

◆ @117

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 157 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 158 of file color.h.


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