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