Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
color_vision.hpp
Go to the documentation of this file.
1
4#pragma once
5
7#include <aegis2d/render/export.hpp>
8
9#include <array>
10#include <cstdint>
11
12namespace aegis2d::render {
13
18enum class ColorVision : std::uint8_t {
20 Typical,
29};
30
35
43[[nodiscard]] AEGIS2D_RENDER_EXPORT Color simulate(Color color, ColorVision vision) noexcept;
44
48[[nodiscard]] AEGIS2D_RENDER_EXPORT float relative_luminance(Color color) noexcept;
49
56[[nodiscard]] AEGIS2D_RENDER_EXPORT float contrast_ratio(Color first, Color second) noexcept;
57
62[[nodiscard]] AEGIS2D_RENDER_EXPORT float lightness(Color color) noexcept;
63
70[[nodiscard]] AEGIS2D_RENDER_EXPORT float color_difference(Color first, Color second) noexcept;
71
72} // namespace aegis2d::render
RGBA color used by the renderer.
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
float color_difference(Color first, Color second) noexcept
Perceived difference between two colors, CIE76 ΔE*ab in CIELAB (D65).
constexpr std::array color_visions
Every ColorVision, to check a palette against each of them.
Definition color_vision.hpp:32
float relative_luminance(Color color) noexcept
Relative luminance of a color, as defined by WCAG 2.
float lightness(Color color) noexcept
Perceived lightness of a color, CIE L*.
Color simulate(Color color, ColorVision vision) noexcept
Color as seen with a color vision.
ColorVision
Kind of color vision.
Definition color_vision.hpp:18
@ Tritanopia
No short-wavelength (blue) cones.
@ Typical
Typical trichromatic vision.
@ Achromatopsia
No color: only lightness, as in grayscale.
@ Protanopia
No long-wavelength (red) cones.
@ Deuteranopia
No medium-wavelength (green) cones.
float contrast_ratio(Color first, Color second) noexcept
WCAG 2 contrast ratio between two colors.
RGBA color with components in [0, 1].
Definition color.hpp:10