BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
color.hpp
1#pragma once
2#include <array>
3#include <cstdint>
4
5namespace bugui
6{
11struct color final
12{
13 using rgba = std::array<uint8_t, 4>;
14
15 enum states : uint8_t
16 {
20 };
21
22 explicit color();
23
26 void set(uint8_t&& red = 0
27 , uint8_t&& green = 0
28 , uint8_t&& blue = 0
29 , uint8_t&& alpha = 255);
30
33 void set_blink(uint8_t&& red
34 , uint8_t&& green
35 , uint8_t&& blue
36 , uint8_t&& alpha = 255
37 , uint8_t&& secondary_red = 0
38 , uint8_t&& secondary_green = 0
39 , uint8_t&& secondary_blue = 0
40 , uint8_t&& secondary_alpha = 255);
41
42
45 void set_pulse(uint8_t&& red
46 , uint8_t&& green
47 , uint8_t&& blue
48 , uint8_t&& alpha = 255
49 , uint8_t&& secondary_red = 0
50 , uint8_t&& secondary_green = 0
51 , uint8_t&& secondary_blue = 0
52 , uint8_t&& secondary_alpha = 255);
53
55 rgba get() const noexcept { return value; };
56
58 rgba get_secondary() const noexcept { return secondary; };
59
61 states get_state() const noexcept { return state; };
62
65 void clear();
68 bool is_clear();
69
70 bool operator== (const color& other) const;
71
72private:
73 rgba value;
74 rgba secondary;
75 states state{constant};
76};
77
78} // namespace bugui
Generic colour class holding RGBA values of a primary and a secondary colour. The blinking and pulsin...
Definition color.hpp:12
bool is_clear()
Checks if the primary colour, secondary colour and state are set to their initial values.
void set_blink(uint8_t &&red, uint8_t &&green, uint8_t &&blue, uint8_t &&alpha=255, uint8_t &&secondary_red=0, uint8_t &&secondary_green=0, uint8_t &&secondary_blue=0, uint8_t &&secondary_alpha=255)
Sets primary and secondary colour along with the blinking state.
void set(uint8_t &&red=0, uint8_t &&green=0, uint8_t &&blue=0, uint8_t &&alpha=255)
Sets the primary colour along with the constant state.
states get_state() const noexcept
Retrieves the current state.
Definition color.hpp:61
rgba get_secondary() const noexcept
Retrieves the secondary colour as rgba values.
Definition color.hpp:58
void set_pulse(uint8_t &&red, uint8_t &&green, uint8_t &&blue, uint8_t &&alpha=255, uint8_t &&secondary_red=0, uint8_t &&secondary_green=0, uint8_t &&secondary_blue=0, uint8_t &&secondary_alpha=255)
Sets primary and secondary colour along with the pulsing state.
void clear()
Resets primary colour, secondary colour and state to their initial values.
states
Definition color.hpp:16
@ blinking
Alternating between primary and secondary.
Definition color.hpp:18
@ constant
Primary colour only.
Definition color.hpp:17
@ pulsing
Smooth cycle between primary and secondary.
Definition color.hpp:19
rgba get() const noexcept
Retrieves the primary colour as rgba values.
Definition color.hpp:55