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