IDS peak ICV v1.0.0
Loading...
Searching...
No Matches
peak_icv_opacity.hpp
Go to the documentation of this file.
1
11#pragma once
12
15
16#include <type_traits>
17#include <cstdint>
18#include <string>
19
20namespace peak
21{
22namespace icv
23{
24namespace experimental
25{
34class Opacity : public detail::IPrintable<Opacity>
35{
36public:
42 constexpr explicit Opacity()
43 : Opacity(maximum)
44 {}
45
55 constexpr explicit Opacity(uint32_t value)
56 : m_value(value)
57 {
58 if (value > maximum)
59 {
61 "Opacity value has to be within the range of " + std::to_string(minimum) + " to " + std::to_string(maximum) + ".");
62 }
63 }
64
72 PEAK_ICV_NO_DISCARD constexpr uint32_t GetValue() const
73 {
74 return m_value;
75 }
76
84 PEAK_ICV_NO_DISCARD static constexpr uint32_t GetMinimum()
85 {
86 return minimum;
87 }
88
96 PEAK_ICV_NO_DISCARD static constexpr uint32_t GetMaximum()
97 {
98 return maximum;
99 }
100
106 template <typename Opacity
108 ,
109 std::enable_if_t<std::is_integral<Opacity>::value, bool> = true
111 >
112 auto operator==(const Opacity& value) const
113 {
114 return static_cast<uint32_t>(value) == m_value;
115 }
116
117protected:
118 void Print(detail::CommaSeperatedStream& stream) const override
119 {
120 stream << GetValue();
121 }
122
123private:
124 static constexpr uint32_t minimum = 0;
125 static constexpr uint32_t maximum = 100;
126 uint32_t m_value{ maximum };
127};
128
129} /* namespace experimental */
130} /* namespace icv */
131} /* namespace peak */
Thrown when a value is outside the allowed range.
Opacity refers to the transparency or the degree to which an object or pixel allows the background to...
constexpr Opacity(uint32_t value)
Constructs an Opacity object with the specified value.
constexpr uint32_t GetValue() const
Retrieve the current opacity value.
static constexpr uint32_t GetMaximum()
Get the largest possible value for opacity.
constexpr Opacity()
Constructs an Opacity object with a default value of 100.
auto operator==(const Opacity &value) const
static constexpr uint32_t GetMinimum()
Get the smallest possible value for opacity.