summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx/VectorN.h
diff options
context:
space:
mode:
authorJelle Raaijmakers <jelle@gmta.nl>2022-03-06 19:12:01 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-07 11:00:45 +0100
commitd75135663b5ff9de86f2e2b003f339c57318615a (patch)
treece7e1a282b50a2c9ae811852ed4b4ffcb82374c3 /Userland/Libraries/LibGfx/VectorN.h
parent439617cf6f27dd3a9ee8be3429c3309bea707bb6 (diff)
downloadserenity-d75135663b5ff9de86f2e2b003f339c57318615a.zip
LibGfx+LibSoftGPU: Add and use `Vector.xy()`
Also use `.xyz()` where appropriate.
Diffstat (limited to 'Userland/Libraries/LibGfx/VectorN.h')
-rw-r--r--Userland/Libraries/LibGfx/VectorN.h7
1 files changed, 6 insertions, 1 deletions
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());
}