diff --git a/src/Avalonia.Visuals/Point.cs b/src/Avalonia.Visuals/Point.cs
index 4cce2c925b..f9ae1f2fe1 100644
--- a/src/Avalonia.Visuals/Point.cs
+++ b/src/Avalonia.Visuals/Point.cs
@@ -76,6 +76,17 @@ namespace Avalonia
return left.Equals(right);
}
+ ///
+ /// Checks for equality between a point and cortege off double numbers s.
+ ///
+ /// The point.
+ /// Cortege off double numbers
+ /// True if the point and cortege off double numbers are equal; otherwise false.
+ public static bool operator ==(Point left, (double x, double y) right)
+ {
+ return !((left._x.Equals(right.x)) && (left._y.Equals(right.y)));
+ }
+
///
/// Checks for inequality between two s.
///
@@ -87,6 +98,17 @@ namespace Avalonia
return !(left == right);
}
+ ///
+ /// Checks for inequality between a point and cortege off double numberss.
+ ///
+ /// The point.
+ /// Cortege off double numbers
+ /// True if the point and cortege off double numbers are unequal; otherwise false.
+ public static bool operator !=(Point left, (double x, double y) right)
+ {
+ return !((left._x == right.x) && (left._y== right.y));
+ }
+
///
/// Adds two points.
///
@@ -109,6 +131,28 @@ namespace Avalonia
return new Point(a._x + b.X, a._y + b.Y);
}
+ ///
+ /// Add a cortege off double numbers
+ ///
+ /// The point.
+ /// cortege off doubles
+ /// A point that is the result of the addition.
+ public static Point operator +(Point a, (double x, double y) b)
+ {
+ return new Point(a._x + b.x, a._y + b.y);
+ }
+
+ ///
+ /// Add a double number to both coordinates
+ ///
+ /// The point.
+ /// double number
+ /// A point that is the result of the addition.
+ public static Point operator +(Point a, double b)
+ {
+ return new Point(a._x + b, a._y + b);
+ }
+
///
/// Subtracts two points.
///
@@ -131,6 +175,28 @@ namespace Avalonia
return new Point(a._x - b.X, a._y - b.Y);
}
+ ///
+ /// Subtracts a cortege off double numbers
+ ///
+ /// The point.
+ /// cortege off doubles
+ /// A point that is the result of the subtraction.
+ public static Point operator -(Point a, (double x, double y) b)
+ {
+ return new Point(a._x - b.x, a._y - b.y);
+ }
+
+ ///
+ /// Subtracts a double number to both coordinates
+ ///
+ /// The point.
+ /// double number
+ /// A point that is the result of the subtraction.
+ public static Point operator -(Point a, double b)
+ {
+ return new Point(a._x - b, a._y - b);
+ }
+
///
/// Multiplies a point by a factor coordinate-wise
///
@@ -147,6 +213,17 @@ namespace Avalonia
/// Points having its coordinates multiplied
public static Point operator *(double k, Point p) => new Point(p.X * k, p.Y * k);
+ ///
+ /// Multiplies a cortege off double numbers
+ ///
+ /// The point.
+ /// cortege off doubles
+ /// Points having its coordinates multiplied.
+ public static Point operator *(Point a, (double x, double y) b)
+ {
+ return new Point(a._x * b.x, a._y * b.y);
+ }
+
///
/// Divides a point by a factor coordinate-wise
///
@@ -155,6 +232,17 @@ namespace Avalonia
/// Points having its coordinates divided
public static Point operator /(Point p, double k) => new Point(p.X / k, p.Y / k);
+ ///
+ /// Divides a point by a cortege off double numbers
+ ///
+ /// The point.
+ /// cortege off doubles
+ /// Points having its coordinates divided
+ public static Point operator /(Point a, (double x, double y) b)
+ {
+ return new Point(a._x / b.x, a._y / b.y);
+ }
+
///
/// Applies a matrix to a point.
///
@@ -267,5 +355,32 @@ namespace Avalonia
{
return new Point(_x, y);
}
+
+ ///
+ /// Returns a new point with the opposite coordinates.
+ ///
+ /// The new point.
+ public Point Miror()
+ {
+ return new Point(-_x, -_y);
+ }
+
+ ///
+ /// Returns a new point with the opposite X coordinate.
+ ///
+ /// The new point.
+ public Point WithMirorX()
+ {
+ return new Point(-_x, _y);
+ }
+
+ ///
+ /// Returns a new point with the opposite Y coordinate.
+ ///
+ /// The new point.
+ public Point WithMirorY()
+ {
+ return new Point(_x, -_y);
+ }
}
}