summaryrefslogtreecommitdiff
path: root/lib/nes/util/rgb.hh
blob: d62c70cb0dbed5c1e8407254074e192d85b9eca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <cstdint>

namespace nes
{
	/// An RGB value.
	class rgb
	{
	public:
		explicit rgb() = default;

		explicit rgb(std::uint8_t const r, std::uint8_t const g, std::uint8_t const b)
			: r{ r }
			, g{ g }
			, b{ b }
		{
		}

		static auto from_hex(std::uint32_t const hex) -> rgb
		{
			auto res = rgb{};
			res.r = (hex & 0x00FF0000) >> 16;
			res.g = (hex & 0x0000FF00) >> 8;
			res.b = (hex & 0x000000FF) >> 0;
			return res;
		}

		std::uint8_t r{ 0 };
		std::uint8_t g{ 0 };
		std::uint8_t b{ 0 };
	};
} // namespace nes