roo_blink
API Documentation for roo_blink
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1#pragma once
2
3#include <inttypes.h>
4
5namespace roo_blink {
6
7/// Simple 24-bit RGB color value.
8class Color {
9 public:
10 /// Creates black (0,0,0).
11 constexpr Color() : rgb_(0) {}
12
13 /// Creates a color from 8-bit RGB components.
14 constexpr Color(uint8_t r, uint8_t g, uint8_t b)
15 : rgb_((r << 16) | (g << 8) | b) {}
16
17 /// Returns the red component.
18 uint8_t r() const { return (uint8_t)(rgb_ >> 16); }
19 /// Returns the green component.
20 uint8_t g() const { return (uint8_t)(rgb_ >> 8); }
21 /// Returns the blue component.
22 uint8_t b() const { return (uint8_t)(rgb_ >> 0); }
23
24 private:
25 uint32_t rgb_;
26};
27
28} // namespace roo_blink