1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
namespace Xamarin.Forms.Platform.Android
{
internal struct IntVector
{
public static explicit operator IntVector(System.Drawing.Size size)
{
return new IntVector(size.Width, size.Height);
}
public static explicit operator IntVector(System.Drawing.Point point)
{
return new IntVector(point.X, point.Y);
}
public static implicit operator System.Drawing.Point(IntVector vector)
{
return new System.Drawing.Point(vector.X, vector.Y);
}
public static implicit operator System.Drawing.Size(IntVector vector)
{
return new System.Drawing.Size(vector.X, vector.Y);
}
public static bool operator ==(IntVector lhs, IntVector rhs)
{
return lhs.X == rhs.X && lhs.Y == rhs.Y;
}
public static bool operator !=(IntVector lhs, IntVector rhs)
{
return !(lhs == rhs);
}
public static System.Drawing.Rectangle operator -(System.Drawing.Rectangle source, IntVector vector) => source + -vector;
public static System.Drawing.Rectangle operator +(System.Drawing.Rectangle source, IntVector vector) => new System.Drawing.Rectangle(source.Location + vector, source.Size);
public static System.Drawing.Point operator -(System.Drawing.Point point, IntVector delta) => point + -delta;
public static System.Drawing.Point operator +(System.Drawing.Point point, IntVector delta) => new System.Drawing.Point(point.X + delta.X, point.Y + delta.Y);
public static IntVector operator -(IntVector vector, IntVector other) => vector + -other;
public static IntVector operator +(IntVector vector, IntVector other) => new IntVector(vector.X + other.X, vector.Y + other.Y);
public static IntVector operator -(IntVector vector) => vector * -1;
public static IntVector operator *(IntVector vector, int scaler) => new IntVector(vector.X * scaler, vector.Y * scaler);
public static IntVector operator /(IntVector vector, int scaler) => new IntVector(vector.X / scaler, vector.Y / scaler);
public static IntVector operator *(IntVector vector, double scaler) => new IntVector((int)(vector.X * scaler), (int)(vector.Y * scaler));
public static IntVector operator /(IntVector vector, double scaler) => vector * (1 / scaler);
internal static IntVector Origin = new IntVector(0, 0);
internal static IntVector XUnit = new IntVector(1, 0);
internal static IntVector YUnit = new IntVector(0, 1);
internal IntVector(int x, int y)
{
X = x;
Y = y;
}
internal int X { get; }
internal int Y { get; }
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
return $"{X},{Y}";
}
}
}
|