From d75135663b5ff9de86f2e2b003f339c57318615a Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sun, 6 Mar 2022 19:12:01 +0100 Subject: LibGfx+LibSoftGPU: Add and use `Vector.xy()` Also use `.xyz()` where appropriate. --- Userland/Libraries/LibGfx/VectorN.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibGfx/VectorN.h') diff --git a/Userland/Libraries/LibGfx/VectorN.h b/Userland/Libraries/LibGfx/VectorN.h index 585fdea353..7913427d93 100644 --- a/Userland/Libraries/LibGfx/VectorN.h +++ b/Userland/Libraries/LibGfx/VectorN.h @@ -201,7 +201,12 @@ public: return AK::sqrt(m_data[0] * m_data[0] + m_data[1] * m_data[1] + m_data[2] * m_data[2] + m_data[3] * m_data[3]); } - [[nodiscard]] constexpr VectorN<3, T> xyz() const requires(N == 4) + [[nodiscard]] constexpr VectorN<2, T> xy() const requires(N >= 3) + { + return VectorN<2, T>(x(), y()); + } + + [[nodiscard]] constexpr VectorN<3, T> xyz() const requires(N >= 4) { return VectorN<3, T>(x(), y(), z()); } -- cgit v1.2.3