IDS peak ICV v1.0.0
Loading...
Searching...
No Matches
peak_icv_color.hpp
Go to the documentation of this file.
1
11#pragma once
12
14#include <peak_icv_c/painting/peak_icv_painter.h>
15
16#include <tuple>
17
18namespace peak
19{
20namespace icv
21{
22namespace experimental
23{
29using red_t = uint16_t;
35using green_t = uint16_t;
41using blue_t = uint16_t;
42
49enum class ColorConstant : uint64_t
50{
56 Black = PEAK_ICV_COLOR_BLACK,
62 Red = PEAK_ICV_COLOR_RED,
68 Red8 = PEAK_ICV_COLOR_RED_8,
74 Red10 = PEAK_ICV_COLOR_RED_10,
80 Red12 = PEAK_ICV_COLOR_RED_12
81};
82
89class Color
90{
91public:
97 constexpr Color() = default;
98
105 constexpr explicit Color(uint64_t colorCodeRaw)
106 : m_colorCode{ colorCodeRaw }
107 {}
108
118 constexpr Color(uint16_t red, uint16_t green, uint16_t blue)
119 : Color(PEAK_ICV_COLOR_CODE(red, green, blue))
120 {}
121
128 constexpr explicit Color(ColorConstant colorCode)
129 : m_colorCode{ static_cast<uint64_t>(colorCode) }
130 {}
131
138 PEAK_ICV_NO_DISCARD constexpr uint16_t GetRed() const
139 {
140 return static_cast<uint16_t>(PEAK_ICV_COLOR_RED_FROM_CODE(m_colorCode));
141 }
142
149 PEAK_ICV_NO_DISCARD constexpr uint16_t GetGreen() const
150 {
151 return static_cast<uint16_t>(PEAK_ICV_COLOR_GREEN_FROM_CODE(m_colorCode));
152 }
153
160 PEAK_ICV_NO_DISCARD constexpr uint16_t GetBlue() const
161 {
162 return static_cast<uint16_t>(PEAK_ICV_COLOR_BLUE_FROM_CODE(m_colorCode));
163 }
164
172 PEAK_ICV_NO_DISCARD constexpr std::tuple<red_t, green_t, blue_t> GetRGB() const
173 {
174 return std::make_tuple(GetRed(), GetGreen(), GetBlue());
175 }
176
183 PEAK_ICV_NO_DISCARD constexpr uint64_t GetRaw() const
184 {
185 return m_colorCode;
186 }
187
193 constexpr bool operator==(const Color& rhs) const
194 {
195 return m_colorCode == rhs.m_colorCode;
196 }
197
203 constexpr bool operator!=(const Color& rhs) const
204 {
205 return !(rhs == *this);
206 }
207
213 constexpr bool operator==(const ColorConstant& rhs) const
214 {
215 return m_colorCode == static_cast<uint64_t>(rhs);
216 }
217
223 constexpr bool operator!=(const ColorConstant& rhs) const
224 {
225 return !(*this == rhs);
226 }
227
228private:
229 uint64_t m_colorCode{};
230};
231
232} /* namespace experimental */
233} /* namespace icv */
234} /* namespace peak */
Color class holding the actual color codes.
constexpr uint16_t GetGreen() const
Returns the green value for the color, that was specified.
constexpr uint16_t GetRed() const
Returns the red value for the color, that was specified.
constexpr Color(uint16_t red, uint16_t green, uint16_t blue)
Creates a Color from red, green and blue.
constexpr Color(ColorConstant colorCode)
Creates a Color a color constant.
constexpr uint64_t GetRaw() const
Returns the current colorCode in its raw format.
constexpr bool operator!=(const ColorConstant &rhs) const
constexpr std::tuple< red_t, green_t, blue_t > GetRGB() const
Returns the current colorCode as Red, Green, Blue The color as a tuple of red, green and blue values.
constexpr bool operator==(const ColorConstant &rhs) const
constexpr uint16_t GetBlue() const
Returns the blue value for the color, that was specified.
constexpr bool operator!=(const Color &rhs) const
constexpr bool operator==(const Color &rhs) const
constexpr Color()=default
Default Color is black.
constexpr Color(uint64_t colorCodeRaw)
The provided color code is one value containing rgb.
uint16_t red_t
Typedef for Color red (value)
uint16_t green_t
Typedef for Color green (value)
uint16_t blue_t
Typedef for Color blue (value)