From 878111abf6475f770ea3959cc5f4259c7d982324 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 8 May 2022 01:54:21 +0200 Subject: [PATCH] LibGfx: Add `VectorN::to_type()` --- Userland/Libraries/LibGfx/VectorN.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index 0ef9d383e1..7d57e4ce65 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -224,6 +224,16 @@ public: return String::formatted("[{},{},{},{}]", x(), y(), z(), w()); } + template + [[nodiscard]] VectorN to_type() const + { + VectorN result; + UNROLL_LOOP + for (auto i = 0u; i < N; ++i) + result.data()[i] = static_cast(m_data[i]); + return result; + } + template [[nodiscard]] VectorN to_rounded() const {