Add math ops

This commit is contained in:
Krzosa Karol
2024-07-02 07:36:21 +02:00
parent e0505dc974
commit 620954631a

View File

@@ -72,23 +72,52 @@ Rect2 CutTop(Rect2 *r, float value) {
return result; return result;
} }
Rect2 operator-(Rect2 r, float value) { // clang-format off
r.min.x -= value; Rect2 operator-(Rect2 r, Rect2 value) { return { r.min.x - value.min.x, r.min.y - value.min.y, r.max.x - value.max.x, r.max.y - value.max.y }; }
r.min.y -= value; Rect2 operator+(Rect2 r, Rect2 value) { return { r.min.x + value.min.x, r.min.y + value.min.y, r.max.x + value.max.x, r.max.y + value.max.y }; }
r.max.x -= value; Rect2 operator*(Rect2 r, Rect2 value) { return { r.min.x * value.min.x, r.min.y * value.min.y, r.max.x * value.max.x, r.max.y * value.max.y }; }
r.max.y -= value; Rect2 operator/(Rect2 r, Rect2 value) { return { r.min.x / value.min.x, r.min.y / value.min.y, r.max.x / value.max.x, r.max.y / value.max.y }; }
return r;
}
Rect2 operator-(Rect2 r, Vec2 value) { Rect2 operator-(Rect2 r, Vec2 value) { return { r.min.x - value.x, r.min.y - value.y, r.max.x - value.x, r.max.y - value.y }; }
r.min.x -= value.x; Rect2 operator+(Rect2 r, Vec2 value) { return { r.min.x + value.x, r.min.y + value.y, r.max.x + value.x, r.max.y + value.y }; }
r.min.y -= value.y; Rect2 operator*(Rect2 r, Vec2 value) { return { r.min.x * value.x, r.min.y * value.y, r.max.x * value.x, r.max.y * value.y }; }
r.max.x -= value.x; Rect2 operator/(Rect2 r, Vec2 value) { return { r.min.x / value.x, r.min.y / value.y, r.max.x / value.x, r.max.y / value.y }; }
r.max.y -= value.y;
return r;
}
Rect2 operator-=(Rect2 &r, Vec2 value) { Rect2 operator-(Rect2 r, float value) { return { r.min.x - value, r.min.y - value, r.max.x - value, r.max.y - value }; }
r = r - value; Rect2 operator+(Rect2 r, float value) { return { r.min.x + value, r.min.y + value, r.max.x + value, r.max.y + value }; }
return r; Rect2 operator*(Rect2 r, float value) { return { r.min.x * value, r.min.y * value, r.max.x * value, r.max.y * value }; }
} Rect2 operator/(Rect2 r, float value) { return { r.min.x / value, r.min.y / value, r.max.x / value, r.max.y / value }; }
Rect2 operator-=(Rect2 &r, Rect2 value) { r = r - value; return r; }
Rect2 operator+=(Rect2 &r, Rect2 value) { r = r + value; return r; }
Rect2 operator*=(Rect2 &r, Rect2 value) { r = r * value; return r; }
Rect2 operator/=(Rect2 &r, Rect2 value) { r = r / value; return r; }
Rect2 operator-=(Rect2 &r, Vec2 value) { r = r - value; return r; }
Rect2 operator+=(Rect2 &r, Vec2 value) { r = r + value; return r; }
Rect2 operator*=(Rect2 &r, Vec2 value) { r = r * value; return r; }
Rect2 operator/=(Rect2 &r, Vec2 value) { r = r / value; return r; }
Rect2 operator-=(Rect2 &r, float value) { r = r - value; return r; }
Rect2 operator+=(Rect2 &r, float value) { r = r + value; return r; }
Rect2 operator*=(Rect2 &r, float value) { r = r * value; return r; }
Rect2 operator/=(Rect2 &r, float value) { r = r / value; return r; }
Vec2 operator-(Vec2 a, Vec2 b) { return {a.x - b.x, a.y - b.y}; }
Vec2 operator+(Vec2 a, Vec2 b) { return {a.x + b.x, a.y + b.y}; }
Vec2 operator*(Vec2 a, Vec2 b) { return {a.x * b.x, a.y * b.y}; }
Vec2 operator/(Vec2 a, Vec2 b) { return {a.x / b.x, a.y / b.y}; }
Vec2 operator-(Vec2 a, float b) { return {a.x - b, a.y - b}; }
Vec2 operator+(Vec2 a, float b) { return {a.x + b, a.y + b}; }
Vec2 operator*(Vec2 a, float b) { return {a.x * b, a.y * b}; }
Vec2 operator/(Vec2 a, float b) { return {a.x / b, a.y / b}; }
Vec2 operator-=(Vec2 &a, Vec2 b) { a = a - b; return a; }
Vec2 operator+=(Vec2 &a, Vec2 b) { a = a + b; return a; }
Vec2 operator*=(Vec2 &a, Vec2 b) { a = a * b; return a; }
Vec2 operator/=(Vec2 &a, Vec2 b) { a = a / b; return a; }
Vec2 operator-=(Vec2 &a, float b) { a = a - b; return a; }
Vec2 operator+=(Vec2 &a, float b) { a = a + b; return a; }
Vec2 operator*=(Vec2 &a, float b) { a = a * b; return a; }
Vec2 operator/=(Vec2 &a, float b) { a = a / b; return a; }
// clang-format on