From e2b9cd16b31f458c919c11b889e6874db25cc9e9 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 27 Oct 2021 00:54:31 -0500 Subject: [PATCH] [nostalgia/core] Add redf, greenf, and bluef functions --- src/nostalgia/core/color.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/nostalgia/core/color.hpp b/src/nostalgia/core/color.hpp index 7e28a8f2..12f636d3 100644 --- a/src/nostalgia/core/color.hpp +++ b/src/nostalgia/core/color.hpp @@ -91,6 +91,22 @@ constexpr uint8_t blue32(Color32 c) noexcept { } +[[nodiscard]] +constexpr float redf(Color16 c) noexcept { + return static_cast(red16(c)) / 31.f; +} + +[[nodiscard]] +constexpr float greenf(Color16 c) noexcept { + return static_cast(green16(c)) / 31.f; +} + +[[nodiscard]] +constexpr float bluef(Color16 c) noexcept { + return static_cast(blue16(c)) / 31.f; +} + + [[nodiscard]] constexpr Color16 color16(uint8_t r, uint8_t g, uint8_t b) noexcept { return r | (g << 5) | (b << 10);