summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2022-01-16 02:11:45 +1100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-18 01:48:51 +0200
commit38fc7361ca795e6c050a0c524e640f130670c129 (patch)
tree1316738bb86116d8d64f7248d800a571714f9e2a /Userland/Libraries/LibGfx
parent53ed93d9095932ba9061f298e86964f177f5034b (diff)
downloadserenity-38fc7361ca795e6c050a0c524e640f130670c129.zip
LibGfx: Add `::xyz()` swizzle operator to `Vector4`
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/Vector4.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Vector4.h b/Userland/Libraries/LibGfx/Vector4.h
index 6f836939ba..5eea391b60 100644
--- a/Userland/Libraries/LibGfx/Vector4.h
+++ b/Userland/Libraries/LibGfx/Vector4.h
@@ -11,6 +11,9 @@
namespace Gfx {
template<typename T>
+class Vector3;
+
+template<typename T>
class Vector4 final {
public:
constexpr Vector4() = default;
@@ -131,6 +134,11 @@ public:
return AK::sqrt(m_x * m_x + m_y * m_y + m_z * m_z + m_w * m_w);
}
+ constexpr Vector3<T> xyz() const
+ {
+ return Vector3<T>(m_x, m_y, m_z);
+ }
+
String to_string() const
{
return String::formatted("[{},{},{},{}]", x(), y(), z(), w());