diff options
author | Jesse Buhagiar <jooster669@gmail.com> | 2022-01-15 13:01:08 +1100 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-01-18 01:48:51 +0200 |
commit | 53ed93d9095932ba9061f298e86964f177f5034b (patch) | |
tree | 11c0e7bf320f01b9f8422a2af6d2b76e97086ffd /Userland/Libraries/LibGfx | |
parent | 27ca7bbbd7fe8c03d2ff2dc6d3af87b9d93bfa4d (diff) | |
download | serenity-53ed93d9095932ba9061f298e86964f177f5034b.zip |
LibGfx: Add unary `operator-()` to Vector2/3/4
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/Vector2.h | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Vector3.h | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Vector4.h | 5 |
3 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Vector2.h b/Userland/Libraries/LibGfx/Vector2.h index 2aa13136b2..43aa58df96 100644 --- a/Userland/Libraries/LibGfx/Vector2.h +++ b/Userland/Libraries/LibGfx/Vector2.h @@ -50,6 +50,11 @@ public: return Vector2(m_x - other.m_x, m_y - other.m_y); } + constexpr Vector2 operator-() const + { + return Vector2(-m_x, -m_y); + } + constexpr Vector2 operator*(const Vector2& other) const { return Vector2(m_x * other.m_x, m_y * other.m_y); diff --git a/Userland/Libraries/LibGfx/Vector3.h b/Userland/Libraries/LibGfx/Vector3.h index d6888c241e..6b7f4ae26d 100644 --- a/Userland/Libraries/LibGfx/Vector3.h +++ b/Userland/Libraries/LibGfx/Vector3.h @@ -55,6 +55,11 @@ public: return Vector3(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z); } + constexpr Vector3 operator-() const + { + return Vector3(-m_x, -m_y, -m_z); + } + constexpr Vector3 operator*(const Vector3& other) const { return Vector3(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z); diff --git a/Userland/Libraries/LibGfx/Vector4.h b/Userland/Libraries/LibGfx/Vector4.h index 06accb44a1..6f836939ba 100644 --- a/Userland/Libraries/LibGfx/Vector4.h +++ b/Userland/Libraries/LibGfx/Vector4.h @@ -60,6 +60,11 @@ public: return Vector4(m_x - other.m_x, m_y - other.m_y, m_z - other.m_z, m_w - other.m_w); } + constexpr Vector4 operator-() const + { + return Vector4(-m_x, -m_y, -m_z, -m_w); + } + constexpr Vector4 operator*(const Vector4& other) const { return Vector4(m_x * other.m_x, m_y * other.m_y, m_z * other.m_z, m_w * other.m_w); |