Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Point.cs
Go to the documentation of this file.
4
5namespace System.Drawing;
6
8[TypeForwardedFrom("System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
9[TypeConverter("System.Drawing.PointConverter, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
10public struct Point : IEquatable<Point>
11{
12 public static readonly Point Empty;
13
14 private int x;
15
16 private int y;
17
18 [Browsable(false)]
19 public readonly bool IsEmpty
20 {
21 get
22 {
23 if (x == 0)
24 {
25 return y == 0;
26 }
27 return false;
28 }
29 }
30
31 public int X
32 {
33 readonly get
34 {
35 return x;
36 }
37 set
38 {
39 x = value;
40 }
41 }
42
43 public int Y
44 {
45 readonly get
46 {
47 return y;
48 }
49 set
50 {
51 y = value;
52 }
53 }
54
55 public Point(int x, int y)
56 {
57 this.x = x;
58 this.y = y;
59 }
60
61 public Point(Size sz)
62 {
63 x = sz.Width;
64 y = sz.Height;
65 }
66
67 public Point(int dw)
68 {
69 x = LowInt16(dw);
70 y = HighInt16(dw);
71 }
72
73 public static implicit operator PointF(Point p)
74 {
75 return new PointF(p.X, p.Y);
76 }
77
78 public static explicit operator Size(Point p)
79 {
80 return new Size(p.X, p.Y);
81 }
82
83 public static Point operator +(Point pt, Size sz)
84 {
85 return Add(pt, sz);
86 }
87
88 public static Point operator -(Point pt, Size sz)
89 {
90 return Subtract(pt, sz);
91 }
92
93 public static bool operator ==(Point left, Point right)
94 {
95 if (left.X == right.X)
96 {
97 return left.Y == right.Y;
98 }
99 return false;
100 }
101
102 public static bool operator !=(Point left, Point right)
103 {
104 return !(left == right);
105 }
106
107 public static Point Add(Point pt, Size sz)
108 {
109 return new Point(pt.X + sz.Width, pt.Y + sz.Height);
110 }
111
112 public static Point Subtract(Point pt, Size sz)
113 {
114 return new Point(pt.X - sz.Width, pt.Y - sz.Height);
115 }
116
117 public static Point Ceiling(PointF value)
118 {
119 return new Point((int)Math.Ceiling(value.X), (int)Math.Ceiling(value.Y));
120 }
121
122 public static Point Truncate(PointF value)
123 {
124 return new Point((int)value.X, (int)value.Y);
125 }
126
127 public static Point Round(PointF value)
128 {
129 return new Point((int)Math.Round(value.X), (int)Math.Round(value.Y));
130 }
131
132 public override readonly bool Equals([NotNullWhen(true)] object? obj)
133 {
134 if (obj is Point)
135 {
136 return Equals((Point)obj);
137 }
138 return false;
139 }
140
141 public readonly bool Equals(Point other)
142 {
143 return this == other;
144 }
145
146 public override readonly int GetHashCode()
147 {
148 return HashCode.Combine(X, Y);
149 }
150
151 public void Offset(int dx, int dy)
152 {
153 X += dx;
154 Y += dy;
155 }
156
157 public void Offset(Point p)
158 {
159 Offset(p.X, p.Y);
160 }
161
162 public override readonly string ToString()
163 {
164 return $"{{X={X},Y={Y}}}";
165 }
166
167 private static short HighInt16(int n)
168 {
169 return (short)((n >> 16) & 0xFFFF);
170 }
171
172 private static short LowInt16(int n)
173 {
174 return (short)(n & 0xFFFF);
175 }
176}
static decimal Round(decimal d)
Definition Math.cs:1096
static double Ceiling(double a)
static bool operator!=(Point left, Point right)
Definition Point.cs:102
readonly bool Equals(Point other)
Definition Point.cs:141
static Point Add(Point pt, Size sz)
Definition Point.cs:107
Point(Size sz)
Definition Point.cs:61
static Point Ceiling(PointF value)
Definition Point.cs:117
override readonly int GetHashCode()
Definition Point.cs:146
static short HighInt16(int n)
Definition Point.cs:167
override readonly bool Equals([NotNullWhen(true)] object? obj)
Definition Point.cs:132
static Point Round(PointF value)
Definition Point.cs:127
static short LowInt16(int n)
Definition Point.cs:172
Point(int x, int y)
Definition Point.cs:55
static readonly Point Empty
Definition Point.cs:12
void Offset(Point p)
Definition Point.cs:157
static Point Subtract(Point pt, Size sz)
Definition Point.cs:112
static Point operator+(Point pt, Size sz)
Definition Point.cs:83
static Point operator-(Point pt, Size sz)
Definition Point.cs:88
override readonly string ToString()
Definition Point.cs:162
static Point Truncate(PointF value)
Definition Point.cs:122
static bool operator==(Point left, Point right)
Definition Point.cs:93
void Offset(int dx, int dy)
Definition Point.cs:151
readonly bool IsEmpty
Definition Point.cs:20