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