summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorJesse Buhagiar <jooster669@gmail.com>2022-01-15 13:01:08 +1100
committerIdan Horowitz <idan.horowitz@gmail.com>2022-01-18 01:48:51 +0200
commit53ed93d9095932ba9061f298e86964f177f5034b (patch)
tree11c0e7bf320f01b9f8422a2af6d2b76e97086ffd /Userland/Libraries/LibGfx
parent27ca7bbbd7fe8c03d2ff2dc6d3af87b9d93bfa4d (diff)
downloadserenity-53ed93d9095932ba9061f298e86964f177f5034b.zip
LibGfx: Add unary `operator-()` to Vector2/3/4
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/Vector2.h5
-rw-r--r--Userland/Libraries/LibGfx/Vector3.h5
-rw-r--r--Userland/Libraries/LibGfx/Vector4.h5
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);