HEBI C++ API  3.9.0
color.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
5 namespace hebi {
6 
8 struct Color {
9 public:
12  Color() {}
13 
18  Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r_(r), g_(g), b_(b), a_(a) {}
19 
24  Color(uint8_t r, uint8_t g, uint8_t b) : r_(r), g_(g), b_(b), a_(255) {}
25 
27  uint8_t getRed() const { return r_; }
29  uint8_t getGreen() const { return g_; }
31  uint8_t getBlue() const { return b_; }
36  uint8_t getAlpha() const { return a_; }
37 
38  void setRed(uint8_t r) { r_ = r; }
39  void setGreen(uint8_t g) { g_ = g; }
40  void setBlue(uint8_t b) { b_ = b; }
41  void setAlpha(uint8_t a) { a_ = a; }
42 
43  uint32_t toInt() const {
44  return (static_cast<uint32_t>(getRed()) << 24) | (static_cast<uint32_t>(getGreen()) << 16) |
45  (static_cast<uint32_t>(getBlue()) << 8) | (static_cast<uint32_t>(getAlpha()));
46  }
47 
48 private:
49  uint8_t r_{};
50  uint8_t g_{};
51  uint8_t b_{};
52  uint8_t a_{};
53 };
54 
55 } // namespace hebi
Definition: arm.cpp:8
uint8_t getBlue() const
Returns the blue channel; value is between 0 and 255.
Definition: color.hpp:31
void setBlue(uint8_t b)
Definition: color.hpp:40
void setGreen(uint8_t g)
Definition: color.hpp:39
void setAlpha(uint8_t a)
Definition: color.hpp:41
uint32_t toInt() const
Definition: color.hpp:43
uint8_t getRed() const
Returns the red channel; value is between 0 and 255.
Definition: color.hpp:27
void setRed(uint8_t r)
Definition: color.hpp:38
Color()
Creates a color object with zero for the red, green, blue, and alpha channels.
Definition: color.hpp:12
uint8_t getAlpha() const
Definition: color.hpp:36
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
Creates a color from the given red, green, blue, and alpha channel values.
Definition: color.hpp:18
uint8_t getGreen() const
Returns the green channel; value is between 0 and 255.
Definition: color.hpp:29
Structure to describe an RGB color.
Definition: color.hpp:8
Color(uint8_t r, uint8_t g, uint8_t b)
Creates a color from the given red, green, and blue values.
Definition: color.hpp:24