summaryrefslogtreecommitdiff
path: root/include/SSVOpenHexagon/Utils/Color.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/SSVOpenHexagon/Utils/Color.hpp')
-rw-r--r--include/SSVOpenHexagon/Utils/Color.hpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/include/SSVOpenHexagon/Utils/Color.hpp b/include/SSVOpenHexagon/Utils/Color.hpp
index 96a81e94..4d01fbb9 100644
--- a/include/SSVOpenHexagon/Utils/Color.hpp
+++ b/include/SSVOpenHexagon/Utils/Color.hpp
@@ -7,13 +7,14 @@
#include "SSVOpenHexagon/Global/Assert.hpp"
#include <SFML/Graphics/Color.hpp>
+#include <SFML/Graphics/Glsl.hpp>
#include <cmath>
namespace hg::Utils {
[[nodiscard, gnu::always_inline, gnu::pure]] inline sf::Color getColorDarkened(
- sf::Color mColor, const float mMultiplier)
+ sf::Color mColor, const float mMultiplier) noexcept
{
SSVOH_ASSERT(mMultiplier != 0.f);
@@ -25,7 +26,7 @@ namespace hg::Utils {
}
[[nodiscard, gnu::always_inline, gnu::pure]] inline sf::Color transformHue(
- const sf::Color& in, const float H)
+ const sf::Color& in, const float H) noexcept
{
const float u{std::cos(H * 3.14f / 180.f)};
const float w{std::sin(H * 3.14f / 180.f)};
@@ -74,8 +75,8 @@ namespace hg::Utils {
return ret(1.f, 0.f, q);
}
-[[nodiscard, gnu::always_inline, gnu::pure]] inline sf::Uint8 componentClamp(
- const float value)
+[[nodiscard, gnu::always_inline, gnu::pure]] inline constexpr sf::Uint8
+componentClamp(const float value) noexcept
{
if(value > 255.f)
{
@@ -90,4 +91,23 @@ namespace hg::Utils {
return static_cast<sf::Uint8>(value);
}
+[[nodiscard, gnu::always_inline, gnu::pure]] inline sf::Glsl::Vec3 toGLSLVec3(
+ const sf::Color& color) noexcept
+{
+ return {//
+ static_cast<float>(color.r) / 255.f,
+ static_cast<float>(color.g) / 255.f,
+ static_cast<float>(color.b) / 255.f};
+}
+
+[[nodiscard, gnu::always_inline, gnu::pure]] inline sf::Glsl::Vec4 toGLSLVec4(
+ const sf::Color& color) noexcept
+{
+ return {//
+ static_cast<float>(color.r) / 255.f,
+ static_cast<float>(color.g) / 255.f,
+ static_cast<float>(color.b) / 255.f,
+ static_cast<float>(color.a) / 255.f};
+}
+
} // namespace hg::Utils