hyperion.ng
ColorRgbw.h
1 #pragma once
2 
3 // STL includes
4 #include <cstdint>
5 #include <iostream>
6 
7 struct ColorRgbw;
8 
13 struct ColorRgbw
14 {
16  uint8_t red;
18  uint8_t green;
20  uint8_t blue;
22  uint8_t white;
23 
25  static ColorRgbw BLACK;
27  static ColorRgbw RED;
29  static ColorRgbw GREEN;
31  static ColorRgbw BLUE;
33  static ColorRgbw YELLOW;
35  static ColorRgbw WHITE;
36 };
37 
39 static_assert(sizeof(ColorRgbw) == 4, "Incorrect size of ColorRgbw");
40 
48 inline std::ostream& operator<<(std::ostream& os, const ColorRgbw& color)
49 {
50  os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "," << unsigned(color.white) << "}";
51  return os;
52 }
53 
54 
56 inline bool operator<(const ColorRgbw & lhs, const ColorRgbw & rhs)
57 {
58  return (lhs.red < rhs.red) && (lhs.green < rhs.green) && (lhs.blue < rhs.blue) && (lhs.white < rhs.white);
59 }
60 
62 inline bool operator<=(const ColorRgbw & lhs, const ColorRgbw & rhs)
63 {
64  return (lhs.red <= rhs.red) && (lhs.green <= rhs.green) && (lhs.blue <= rhs.blue) && (lhs.white < rhs.white);
65 }
uint8_t green
The green color channel.
Definition: ColorRgbw.h:18
uint8_t blue
The blue color channel.
Definition: ColorRgbw.h:20
static ColorRgbw YELLOW
&#39;Yellow&#39; RgbColor (255, 255, 0, 0)
Definition: ColorRgbw.h:33
static ColorRgbw GREEN
&#39;Green&#39; RgbColor (0, 255, 0, 0)
Definition: ColorRgbw.h:29
uint8_t white
The white color channel.
Definition: ColorRgbw.h:22
static ColorRgbw BLACK
&#39;Black&#39; RgbColor (0, 0, 0, 0)
Definition: ColorRgbw.h:25
static ColorRgbw WHITE
&#39;White&#39; RgbColor (0, 0, 0, 255)
Definition: ColorRgbw.h:35
static ColorRgbw RED
&#39;Red&#39; RgbColor (255, 0, 0, 0)
Definition: ColorRgbw.h:27
Plain-Old-Data structure containing the red-green-blue color specification.
Definition: ColorRgbw.h:13
uint8_t red
The red color channel.
Definition: ColorRgbw.h:16
static ColorRgbw BLUE
&#39;Blue&#39; RgbColor (0, 0, 255, 0)
Definition: ColorRgbw.h:31