|
| 1 | +using System; |
| 2 | + |
| 3 | +namespace Flow.Launcher.Infrastructure.UserSettings; |
| 4 | + |
| 5 | +public record struct Point2D(double X, double Y) |
| 6 | +{ |
| 7 | + public static implicit operator Point2D((double X, double Y) point) |
| 8 | + { |
| 9 | + return new Point2D(point.X, point.Y); |
| 10 | + } |
| 11 | + |
| 12 | + public static Point2D operator +(Point2D point1, Point2D point2) |
| 13 | + { |
| 14 | + return new Point2D(point1.X + point2.X, point1.Y + point2.Y); |
| 15 | + } |
| 16 | + |
| 17 | + public static Point2D operator -(Point2D point1, Point2D point2) |
| 18 | + { |
| 19 | + return new Point2D(point1.X - point2.X, point1.Y - point2.Y); |
| 20 | + } |
| 21 | + |
| 22 | + public static Point2D operator *(Point2D point, double scalar) |
| 23 | + { |
| 24 | + return new Point2D(point.X * scalar, point.Y * scalar); |
| 25 | + } |
| 26 | + |
| 27 | + public static Point2D operator /(Point2D point, double scalar) |
| 28 | + { |
| 29 | + return new Point2D(point.X / scalar, point.Y / scalar); |
| 30 | + } |
| 31 | + |
| 32 | + public static Point2D operator /(Point2D point1, Point2D point2) |
| 33 | + { |
| 34 | + return new Point2D(point1.X / point2.X, point1.Y / point2.Y); |
| 35 | + } |
| 36 | + |
| 37 | + public static Point2D operator *(Point2D point1, Point2D point2) |
| 38 | + { |
| 39 | + return new Point2D(point1.X * point2.X, point1.Y * point2.Y); |
| 40 | + } |
| 41 | + |
| 42 | + public Point2D Clamp(Point2D min, Point2D max) |
| 43 | + { |
| 44 | + return new Point2D(Math.Clamp(X, min.X, max.X), Math.Clamp(Y, min.Y, max.Y)); |
| 45 | + } |
| 46 | +} |
0 commit comments