Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
color.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include <cstdint>
5
6namespace Flint {
13 struct Color {
14 unsigned char r, g, b, a;
15
16 constexpr Color()
17 : r(0),
18 g(0),
19 b(0),
20 a(255) {
21 }
22
31 constexpr Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255)
32 : r(r),
33 g(g),
34 b(b),
35 a(a) {
36 }
37
38 constexpr bool operator==(const Color &other) const {
39 return r == other.r && g == other.g && b == other.b && a == other.a;
40 }
41 };
42
46 namespace Colors {
47 constexpr Color white{255, 255, 255, 255};
48 constexpr Color black{0, 0, 0, 255};
49 constexpr Color red{255, 0, 0, 255};
50 constexpr Color green{0, 255, 0, 255};
51 constexpr Color blue{0, 0, 255, 255};
52 constexpr Color yellow{255, 255, 0, 255};
53 constexpr Color cyan{0, 255, 255, 255};
54 constexpr Color magenta{255, 0, 255, 255};
55 constexpr Color transparent{0, 0, 0, 0};
56 }
57}
constexpr Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Construct a color from explicit RGBA components.
Definition color.h:31
RGBA color with 8-bit unsigned components.
Definition color.h:13