diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-03-06 19:12:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-07 11:00:45 +0100 |
commit | d75135663b5ff9de86f2e2b003f339c57318615a (patch) | |
tree | ce7e1a282b50a2c9ae811852ed4b4ffcb82374c3 /Userland/Libraries/LibGfx/VectorN.h | |
parent | 439617cf6f27dd3a9ee8be3429c3309bea707bb6 (diff) | |
download | serenity-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.h | 7 |
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()); } |