Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
color.hpp
Go to the documentation of this file.
1
3#pragma once
4
5#include <cstdint>
6
7namespace aegis2d::render {
8
10struct Color {
12 float r = 0.0F;
14 float g = 0.0F;
16 float b = 0.0F;
18 float a = 1.0F;
19};
20
25[[nodiscard]] constexpr Color rgb(std::uint32_t hex, float alpha = 1.0F) noexcept {
26 constexpr float max = 255.0F;
27 return {.r = static_cast<float>((hex >> 16U) & 0xFFU) / max,
28 .g = static_cast<float>((hex >> 8U) & 0xFFU) / max,
29 .b = static_cast<float>(hex & 0xFFU) / max,
30 .a = alpha};
31}
32
33} // namespace aegis2d::render
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
constexpr Color rgb(std::uint32_t hex, float alpha=1.0F) noexcept
Color from its hexadecimal sRGB code, as design tools and palettes give it.
Definition color.hpp:25
RGBA color with components in [0, 1].
Definition color.hpp:10
float a
Alpha component, 1 for opaque.
Definition color.hpp:18
float g
Green component.
Definition color.hpp:14
float b
Blue component.
Definition color.hpp:16
float r
Red component.
Definition color.hpp:12