BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
color.hpp
1#pragma once
2#include <bugui/concepts/color.hpp>
3
4#include <array>
5#include <cstdint>
6
7namespace bugui
8{
13struct color final
14{
15 using rgba = std::array<uint8_t, 4>;
16
17 enum states : uint8_t
18 {
22 };
23
24 explicit color();
25 color(uint8_t&& red
26 , uint8_t&& green
27 , uint8_t&& blue
28 , uint8_t&& alpha = 255);
29
32 void set(uint8_t&& red = 0
33 , uint8_t&& green = 0
34 , uint8_t&& blue = 0
35 , uint8_t&& alpha = 255);
36
39 void set_blink(uint8_t&& red
40 , uint8_t&& green
41 , uint8_t&& blue
42 , uint8_t&& alpha = 255);
43
44
47 void set_pulse(uint8_t&& red
48 , uint8_t&& green
49 , uint8_t&& blue
50 , uint8_t&& alpha = 255);
51
53 rgba get() const noexcept { return value; };
54
56 states get_state() const noexcept { return state; };
57
60 void clear();
63 bool is_clear();
64
65 bool operator== (const color& other) const;
66
67private:
68 rgba value;
69 states state{constant};
70};
71
72} // namespace bugui
Generic colour class holding RGBA coloour values. The blinking and pulsing states indicate discrete o...
Definition color.hpp:14
bool is_clear()
Checks if the primary colour, secondary colour and state are set to their initial values.
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.
void set_pulse(uint8_t &&red, uint8_t &&green, uint8_t &&blue, uint8_t &&alpha=255)
Sets primary and secondary colour along with the pulsing state.
states get_state() const noexcept
Retrieves the current state.
Definition color.hpp:56
void clear()
Resets primary colour, secondary colour and state to their initial values.
states
Definition color.hpp:18
@ blinking
Alternating between the colour and black.
Definition color.hpp:20
@ constant
Constant colour.
Definition color.hpp:19
@ pulsing
Smooth cycle between the colour and black.
Definition color.hpp:21
void set_blink(uint8_t &&red, uint8_t &&green, uint8_t &&blue, uint8_t &&alpha=255)
Sets primary and secondary colour along with the blinking state.
rgba get() const noexcept
Retrieves the primary colour as rgba values.
Definition color.hpp:53