From a5f55be257eee0886c4fdd9287c9d91c9de22d8d Mon Sep 17 00:00:00 2001 From: frank Date: Mon, 4 Dec 2023 21:53:49 -0500 Subject: [PATCH] function to get sb::Color as glm::vec4 --- src/Color.cpp | 5 +++++ src/Color.hpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Color.cpp b/src/Color.cpp index b5c523e..940a7c6 100644 --- a/src/Color.cpp +++ b/src/Color.cpp @@ -91,6 +91,11 @@ bool sb::Color::operator<(const sb::Color& color) const return r < color.r || g < color.g || b < color.b || a < color.a; } +glm::vec4 sb::Color::normal() const +{ + return glm::vec4{r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f}; +} + std::ostream& std::operator<<(std::ostream& out, const sb::Color& color) { float h, s, v; diff --git a/src/Color.hpp b/src/Color.hpp index c6c77e8..69e98f7 100644 --- a/src/Color.hpp +++ b/src/Color.hpp @@ -55,6 +55,11 @@ public: bool operator!=(const Color&) const; bool operator<(const Color&) const; + /*! + * Get the color's RGBA value represented as a 4D vector of values between 0.0 and 1.0. + */ + glm::vec4 normal() const; + template Color(Type red, Type green, Type blue, Type alpha = 255) {