| | 1 | | // Copyright (c) 2020-2024 dotBunny Inc. |
| | 2 | | // dotBunny licenses this file to you under the BSL-1.0 license. |
| | 3 | | // See the LICENSE file in the project root for more information. |
| | 4 | |
|
| | 5 | | using System; |
| | 6 | | using System.ComponentModel; |
| | 7 | | using System.Diagnostics; |
| | 8 | | using System.Runtime.CompilerServices; |
| | 9 | | using Unity.Mathematics; |
| | 10 | |
|
| | 11 | | namespace GDX.Mathematics |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// A <see cref="byte" /> vector. |
| | 15 | | /// </summary> |
| | 16 | | [DebuggerTypeProxy(typeof(DebuggerProxy))] |
| | 17 | | [Serializable] |
| | 18 | | public struct Byte2 : IEquatable<Byte2>, IFormattable |
| | 19 | | { |
| | 20 | | /// <summary> |
| | 21 | | /// X <see cref="byte" />. |
| | 22 | | /// </summary> |
| | 23 | | public byte X; |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Y <see cref="byte" />. |
| | 27 | | /// </summary> |
| | 28 | | public byte Y; |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Create a <see cref="Byte2" /> from two <see cref="int" /> values. |
| | 32 | | /// </summary> |
| | 33 | | /// <param name="x">X value.</param> |
| | 34 | | /// <param name="y">Y value.</param> |
| | 35 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 36 | | public Byte2(int x, int y) |
| 34 | 37 | | { |
| 34 | 38 | | X = (byte)x; |
| 34 | 39 | | Y = (byte)y; |
| 34 | 40 | | } |
| | 41 | |
|
| | 42 | | /// <summary> |
| | 43 | | /// Constructs a <see cref="Byte2" /> from two <see cref="byte" /> values. |
| | 44 | | /// </summary> |
| | 45 | | /// <param name="x">X value.</param> |
| | 46 | | /// <param name="y">Y value.</param> |
| | 47 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 48 | | public Byte2(byte x, byte y) |
| 5 | 49 | | { |
| 5 | 50 | | X = x; |
| 5 | 51 | | Y = y; |
| 5 | 52 | | } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// Constructs a <see cref="Byte2" /> from a <see cref="Byte2" /> value. |
| | 56 | | /// </summary> |
| | 57 | | /// <param name="xy">The value to copy.</param> |
| | 58 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 59 | | public Byte2(Byte2 xy) |
| 1 | 60 | | { |
| 1 | 61 | | X = xy.X; |
| 1 | 62 | | Y = xy.Y; |
| 1 | 63 | | } |
| | 64 | |
|
| | 65 | | /// <summary> |
| | 66 | | /// Constructs a <see cref="Byte2" /> from a single <see cref="byte" /> value by assigning it to every compo |
| | 67 | | /// </summary> |
| | 68 | | /// <param name="v">The value to copy to <see cref="X" /> and <see cref="Y" />.</param> |
| | 69 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 70 | | public Byte2(byte v) |
| 2 | 71 | | { |
| 2 | 72 | | X = v; |
| 2 | 73 | | Y = v; |
| 2 | 74 | | } |
| | 75 | |
|
| | 76 | | /// <summary> |
| | 77 | | /// Constructs a <see cref="Byte2" /> from a single <see cref="bool" /> value by converting it to <see cref= |
| | 78 | | /// and assigning it to every component. |
| | 79 | | /// </summary> |
| | 80 | | /// <param name="v">The <see cref="bool" /> value to transcribe.</param> |
| | 81 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 82 | | public Byte2(bool v) |
| 2 | 83 | | { |
| 2 | 84 | | X = v ? (byte)255 : (byte)0; |
| 2 | 85 | | Y = v ? (byte)255 : (byte)0; |
| 2 | 86 | | } |
| | 87 | |
|
| | 88 | | /// <summary> |
| | 89 | | /// Constructs a <see cref="Byte2" /> from a single <see cref="float" /> value by converting it to <see cref |
| | 90 | | /// and assigning it to every component. |
| | 91 | | /// </summary> |
| | 92 | | /// <param name="v">The <see cref="float" /> value to transcribe.</param> |
| | 93 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 94 | | public Byte2(float v) |
| 2 | 95 | | { |
| 2 | 96 | | X = (byte)v; |
| 2 | 97 | | Y = (byte)v; |
| 2 | 98 | | } |
| | 99 | |
|
| | 100 | | /// <summary> |
| | 101 | | /// Constructs a <see cref="Byte2" /> from a single <see cref="double" /> value by converting it to <see cre |
| | 102 | | /// and assigning it to every component. |
| | 103 | | /// </summary> |
| | 104 | | /// <param name="v">The <see cref="double" /> value to transcribe.</param> |
| | 105 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 106 | | public Byte2(double v) |
| 2 | 107 | | { |
| 2 | 108 | | X = (byte)v; |
| 2 | 109 | | Y = (byte)v; |
| 2 | 110 | | } |
| | 111 | |
|
| | 112 | | /// <summary> |
| | 113 | | /// Constructs a <see cref="Byte2" /> from a <see cref="Unity.Mathematics.bool2" /> by conversion. |
| | 114 | | /// </summary> |
| | 115 | | /// <param name="v">The value to transcribe.</param> |
| | 116 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 117 | | public Byte2(bool2 v) |
| 2 | 118 | | { |
| 2 | 119 | | X = v.x ? (byte)255 : (byte)0; |
| 2 | 120 | | Y = v.y ? (byte)255 : (byte)0; |
| 2 | 121 | | } |
| | 122 | |
|
| | 123 | | /// <summary> |
| | 124 | | /// Constructs a <see cref="Byte2" /> from a <see cref="Unity.Mathematics.float2" /> by conversion. |
| | 125 | | /// </summary> |
| | 126 | | /// <param name="v">The value to transcribe.</param> |
| | 127 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 128 | | public Byte2(float2 v) |
| 2 | 129 | | { |
| 2 | 130 | | X = (byte)v.x; |
| 2 | 131 | | Y = (byte)v.y; |
| 2 | 132 | | } |
| | 133 | |
|
| | 134 | | /// <summary> |
| | 135 | | /// Constructs a <see cref="Byte2" /> from a <see cref="Unity.Mathematics.double2" /> by conversion. |
| | 136 | | /// </summary> |
| | 137 | | /// <param name="v">The value to transcribe.</param> |
| | 138 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 139 | | public Byte2(double2 v) |
| 2 | 140 | | { |
| 2 | 141 | | X = (byte)v.x; |
| 2 | 142 | | Y = (byte)v.y; |
| 2 | 143 | | } |
| | 144 | |
|
| | 145 | | /// <summary> |
| | 146 | | /// Get a new <see cref="Byte2" /> created with <see cref="X" /> as both components. |
| | 147 | | /// </summary> |
| | 148 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 149 | | #pragma warning disable IDE1006 |
| | 150 | | // ReSharper disable once InconsistentNaming |
| | 151 | | public Byte2 XX |
| | 152 | | #pragma warning restore IDE1006 |
| | 153 | | { |
| | 154 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 1 | 155 | | get => new Byte2(X, X); |
| | 156 | | } |
| | 157 | |
|
| | 158 | | /// <summary> |
| | 159 | | /// Get a new <see cref="Byte2" /> created with identical components. |
| | 160 | | /// </summary> |
| | 161 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 162 | | #pragma warning disable IDE1006 |
| | 163 | | // ReSharper disable once InconsistentNaming |
| | 164 | | public Byte2 XY |
| | 165 | | #pragma warning restore IDE1006 |
| | 166 | | { |
| | 167 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 1 | 168 | | get => new Byte2(X, Y); |
| | 169 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 170 | | set |
| 1 | 171 | | { |
| 1 | 172 | | X = value.X; |
| 1 | 173 | | Y = value.Y; |
| 1 | 174 | | } |
| | 175 | | } |
| | 176 | |
|
| | 177 | | /// <summary> |
| | 178 | | /// Get a new <see cref="Byte2" /> created with swapped components. |
| | 179 | | /// </summary> |
| | 180 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 181 | | #pragma warning disable IDE1006 |
| | 182 | | // ReSharper disable once InconsistentNaming |
| | 183 | | public Byte2 YX |
| | 184 | | #pragma warning restore IDE1006 |
| | 185 | | { |
| | 186 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 1 | 187 | | get => new Byte2(Y, X); |
| | 188 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 189 | | set |
| 1 | 190 | | { |
| 1 | 191 | | Y = value.X; |
| 1 | 192 | | X = value.Y; |
| 1 | 193 | | } |
| | 194 | | } |
| | 195 | |
|
| | 196 | | /// <summary> |
| | 197 | | /// Get a new <see cref="Byte2" /> created with <see cref="Y" /> as both components. |
| | 198 | | /// </summary> |
| | 199 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 200 | | #pragma warning disable IDE1006 |
| | 201 | | // ReSharper disable once InconsistentNaming |
| | 202 | | public Byte2 YY |
| | 203 | | #pragma warning restore IDE1006 |
| | 204 | | { |
| | 205 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| 1 | 206 | | get => new Byte2(Y, Y); |
| | 207 | | } |
| | 208 | |
|
| | 209 | | /// <summary> |
| | 210 | | /// Get the <see cref="byte" /> at the provided <paramref name="index" />. |
| | 211 | | /// </summary> |
| | 212 | | /// <param name="index">Returns the byte element at a specified index.</param> |
| | 213 | | /// <exception cref="IndexOutOfRangeException">Out of range check.</exception> |
| | 214 | | public unsafe byte this[int index] |
| | 215 | | { |
| | 216 | | get |
| 3 | 217 | | { |
| | 218 | | #if ENABLE_UNITY_COLLECTIONS_CHECKS |
| 3 | 219 | | if ((uint)index >= 2) |
| 1 | 220 | | { |
| 1 | 221 | | throw new IndexOutOfRangeException("The index must be between[0...1]"); |
| | 222 | | } |
| | 223 | | #endif // ENABLE_UNITY_COLLECTIONS_CHECKS |
| 2 | 224 | | fixed (Byte2* array = &this) |
| 2 | 225 | | { |
| 2 | 226 | | return ((byte*)array)[index]; |
| | 227 | | } |
| 2 | 228 | | } |
| | 229 | | set |
| 2 | 230 | | { |
| | 231 | | #if ENABLE_UNITY_COLLECTIONS_CHECKS |
| 2 | 232 | | if ((uint)index >= 2) |
| 1 | 233 | | { |
| 1 | 234 | | throw new IndexOutOfRangeException("The index must be between[0...1]"); |
| | 235 | | } |
| | 236 | | #endif // ENABLE_UNITY_COLLECTIONS_CHECKS |
| 1 | 237 | | fixed (byte* array = &X) |
| 1 | 238 | | { |
| 1 | 239 | | array[index] = value; |
| 1 | 240 | | } |
| 1 | 241 | | } |
| | 242 | | } |
| | 243 | |
|
| | 244 | | /// <summary> |
| | 245 | | /// Does the <see cref="Byte2" /> equal another <see cref="Byte2" />. |
| | 246 | | /// </summary> |
| | 247 | | /// <param name="rhs">Target <see cref="Byte2" /> to compare with.</param> |
| | 248 | | /// <returns>Returns true if the <see cref="Byte2" /> is equal to a given <see cref="Byte2" />, false otherwise. |
| | 249 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 250 | | public bool Equals(Byte2 rhs) |
| 2 | 251 | | { |
| 2 | 252 | | return X == rhs.X && Y == rhs.Y; |
| 2 | 253 | | } |
| | 254 | |
|
| | 255 | | /// <summary> |
| | 256 | | /// Convert the <see cref="Byte2" /> to a <see cref="string" /> using the provided <paramref name="format" / |
| | 257 | | /// </summary> |
| | 258 | | /// <param name="format">Specified format <see cref="string" />.</param> |
| | 259 | | /// <param name="formatProvider">Culture-specific format information.</param> |
| | 260 | | /// <returns> |
| | 261 | | /// Returns a string representation of the <see cref="Byte2" /> using a specified format and culture-specifi |
| | 262 | | /// format information. |
| | 263 | | /// </returns> |
| | 264 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 265 | | public string ToString(string format, IFormatProvider formatProvider) |
| 1 | 266 | | { |
| 1 | 267 | | return $"Byte2({X.ToString(format, formatProvider)},{Y.ToString(format, formatProvider)})"; |
| 1 | 268 | | } |
| | 269 | |
|
| | 270 | | /// <summary> |
| | 271 | | /// Does the <see cref="Byte2" /> equal another <see cref="object" /> (casted). |
| | 272 | | /// </summary> |
| | 273 | | /// <param name="o">Target <see cref="object" /> to compare with.</param> |
| | 274 | | /// <returns>Returns true if the <see cref="Byte2" /> is equal to a given <see cref="Byte2" />, false otherwise. |
| | 275 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 276 | | public override bool Equals(object o) |
| 1 | 277 | | { |
| 1 | 278 | | return o != null && Equals((Byte2)o); |
| 1 | 279 | | } |
| | 280 | |
|
| | 281 | |
|
| | 282 | | /// <summary> |
| | 283 | | /// Implicitly converts a single <see cref="byte" /> value to a <see cref="Byte2" /> by assigning it to ever |
| | 284 | | /// component. |
| | 285 | | /// </summary> |
| | 286 | | /// <param name="v">The <see cref="byte" /> value to transcribe.</param> |
| | 287 | | /// <returns>A new <see cref="Byte2" />.</returns> |
| | 288 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 289 | | public static implicit operator Byte2(byte v) |
| 1 | 290 | | { |
| 1 | 291 | | return new Byte2(v); |
| 1 | 292 | | } |
| | 293 | |
|
| | 294 | | /// <summary> |
| | 295 | | /// Explicitly converts a single <see cref="bool" /> value to a <see cref="Byte2" /> by converting it to |
| | 296 | | /// <see cref="byte" /> and assigning it to every component. |
| | 297 | | /// </summary> |
| | 298 | | /// <param name="v">The <see cref="bool" /> value to transcribe.</param> |
| | 299 | | /// <returns>A new <see cref="Byte2" />.</returns> |
| | 300 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 301 | | public static explicit operator Byte2(bool v) |
| 1 | 302 | | { |
| 1 | 303 | | return new Byte2(v); |
| 1 | 304 | | } |
| | 305 | |
|
| | 306 | | /// <summary> |
| | 307 | | /// Explicitly converts a single <see cref="float" /> value to a <see cref="Byte2" /> by converting it to |
| | 308 | | /// <see cref="byte" /> and assigning it to every component. |
| | 309 | | /// </summary> |
| | 310 | | /// <param name="v">The <see cref="float" /> value to transcribe.</param> |
| | 311 | | /// <returns>A new <see cref="Byte2" />.</returns> |
| | 312 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 313 | | public static explicit operator Byte2(float v) |
| 1 | 314 | | { |
| 1 | 315 | | return new Byte2(v); |
| 1 | 316 | | } |
| | 317 | |
|
| | 318 | | /// <summary> |
| | 319 | | /// Explicitly converts a single <see cref="double" /> value to a <see cref="Byte2" /> by converting it to |
| | 320 | | /// <see cref="byte" /> and assigning it to every component. |
| | 321 | | /// </summary> |
| | 322 | | /// <param name="v">The <see cref="double" /> value to transcribe.</param> |
| | 323 | | /// <returns>A new <see cref="Byte2" />.</returns> |
| | 324 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 325 | | public static explicit operator Byte2(double v) |
| 1 | 326 | | { |
| 1 | 327 | | return new Byte2(v); |
| 1 | 328 | | } |
| | 329 | |
|
| | 330 | | /// <summary> |
| | 331 | | /// Multiply two <see cref="Byte2" />. |
| | 332 | | /// </summary> |
| | 333 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 334 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 335 | | /// <returns>Returns the result of a multiplication operation on two <see cref="Byte2" />.</returns> |
| | 336 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 337 | | public static Byte2 operator *(Byte2 lhs, Byte2 rhs) |
| 1 | 338 | | { |
| 1 | 339 | | return new Byte2(lhs.X * rhs.X, lhs.Y * rhs.Y); |
| 1 | 340 | | } |
| | 341 | |
|
| | 342 | | /// <summary> |
| | 343 | | /// Multiply a <see cref="Byte2" /> by a <see cref="byte" />. |
| | 344 | | /// </summary> |
| | 345 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 346 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 347 | | /// <returns> |
| | 348 | | /// Returns the result of a multiplication operation on a <see cref="Byte2" /> and a |
| | 349 | | /// <see cref="byte" /> value. |
| | 350 | | /// </returns> |
| | 351 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 352 | | public static Byte2 operator *(Byte2 lhs, byte rhs) |
| 1 | 353 | | { |
| 1 | 354 | | return new Byte2(lhs.X * rhs, lhs.Y * rhs); |
| 1 | 355 | | } |
| | 356 | |
|
| | 357 | | /// <summary> |
| | 358 | | /// Multiply a <see cref="byte" /> by a <see cref="Byte2" />. |
| | 359 | | /// </summary> |
| | 360 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 361 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 362 | | /// <returns> |
| | 363 | | /// Returns the result of a multiplication operation on a <see cref="byte" /> and a |
| | 364 | | /// <see cref="Byte2" /> value. |
| | 365 | | /// </returns> |
| | 366 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 367 | | public static Byte2 operator *(byte lhs, Byte2 rhs) |
| 1 | 368 | | { |
| 1 | 369 | | return new Byte2(lhs * rhs.X, lhs * rhs.Y); |
| 1 | 370 | | } |
| | 371 | |
|
| | 372 | | /// <summary> |
| | 373 | | /// Add two <see cref="Byte2" />. |
| | 374 | | /// </summary> |
| | 375 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 376 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 377 | | /// <returns>Returns the result of an addition operation on two <see cref="Byte2" />.</returns> |
| | 378 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 379 | | public static Byte2 operator +(Byte2 lhs, Byte2 rhs) |
| 1 | 380 | | { |
| 1 | 381 | | return new Byte2(lhs.X + rhs.X, lhs.Y + rhs.Y); |
| 1 | 382 | | } |
| | 383 | |
|
| | 384 | | /// <summary> |
| | 385 | | /// Add a <see cref="byte" /> to both components of a <see cref="Byte2" />. |
| | 386 | | /// </summary> |
| | 387 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 388 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 389 | | /// <returns> |
| | 390 | | /// Returns the result of an addition operation on an <see cref="Byte2" /> and an <see cref="byte" /> |
| | 391 | | /// value. |
| | 392 | | /// </returns> |
| | 393 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 394 | | public static Byte2 operator +(Byte2 lhs, byte rhs) |
| 1 | 395 | | { |
| 1 | 396 | | return new Byte2(lhs.X + rhs, lhs.Y + rhs); |
| 1 | 397 | | } |
| | 398 | |
|
| | 399 | | /// <summary> |
| | 400 | | /// Add a <see cref="Byte2" /> to a <see cref="byte" />. |
| | 401 | | /// </summary> |
| | 402 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 403 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 404 | | /// <returns> |
| | 405 | | /// Returns the result of an addition operation on an <see cref="byte" /> value and an |
| | 406 | | /// <see cref="Byte2" />. |
| | 407 | | /// </returns> |
| | 408 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 409 | | public static Byte2 operator +(byte lhs, Byte2 rhs) |
| 1 | 410 | | { |
| 1 | 411 | | return new Byte2(lhs + rhs.X, lhs + rhs.Y); |
| 1 | 412 | | } |
| | 413 | |
|
| | 414 | | /// <summary> |
| | 415 | | /// Subtract a <see cref="Byte2" /> from another <see cref="Byte2" />. |
| | 416 | | /// </summary> |
| | 417 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 418 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 419 | | /// <returns>Returns the result of a subtraction operation on two <see cref="Byte2" />.</returns> |
| | 420 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 421 | | public static Byte2 operator -(Byte2 lhs, Byte2 rhs) |
| 0 | 422 | | { |
| 0 | 423 | | return new Byte2(lhs.X - rhs.X, lhs.Y - rhs.Y); |
| 0 | 424 | | } |
| | 425 | |
|
| | 426 | | /// <summary> |
| | 427 | | /// Subtract a <see cref="byte" /> from both components of a <see cref="Byte2" />. |
| | 428 | | /// </summary> |
| | 429 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 430 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 431 | | /// <returns> |
| | 432 | | /// Returns the result of a subtraction operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 433 | | /// value. |
| | 434 | | /// </returns> |
| | 435 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 436 | | public static Byte2 operator -(Byte2 lhs, byte rhs) |
| 0 | 437 | | { |
| 0 | 438 | | return new Byte2(lhs.X - rhs, lhs.Y - rhs); |
| 0 | 439 | | } |
| | 440 | |
|
| | 441 | | /// <summary> |
| | 442 | | /// Subtract both components of a <see cref="Byte2" /> from a <see cref="byte" />. |
| | 443 | | /// </summary> |
| | 444 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 445 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 446 | | /// <returns> |
| | 447 | | /// Returns the result of a subtraction operation on an <see cref="byte" /> value and an |
| | 448 | | /// <see cref="Byte2" />. |
| | 449 | | /// </returns> |
| | 450 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 451 | | public static Byte2 operator -(byte lhs, Byte2 rhs) |
| 0 | 452 | | { |
| 0 | 453 | | return new Byte2(lhs - rhs.X, lhs - rhs.Y); |
| 0 | 454 | | } |
| | 455 | |
|
| | 456 | | /// <summary> |
| | 457 | | /// Divide a <see cref="Byte2" /> by another <see cref="Byte2" />. |
| | 458 | | /// </summary> |
| | 459 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 460 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 461 | | /// <returns>Returns the result of a division operation on two <see cref="Byte2" />.</returns> |
| | 462 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 463 | | public static Byte2 operator /(Byte2 lhs, Byte2 rhs) |
| 0 | 464 | | { |
| 0 | 465 | | return new Byte2(lhs.X / rhs.X, lhs.Y / rhs.Y); |
| 0 | 466 | | } |
| | 467 | |
|
| | 468 | | /// <summary> |
| | 469 | | /// Divide a <see cref="Byte2" /> by a <see cref="byte" />. |
| | 470 | | /// </summary> |
| | 471 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 472 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 473 | | /// <returns> |
| | 474 | | /// Returns the result of a division operation on a <see cref="Byte2" /> and <see cref="byte" /> |
| | 475 | | /// value. |
| | 476 | | /// </returns> |
| | 477 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 478 | | public static Byte2 operator /(Byte2 lhs, byte rhs) |
| 0 | 479 | | { |
| 0 | 480 | | return new Byte2(lhs.X / rhs, lhs.Y / rhs); |
| 0 | 481 | | } |
| | 482 | |
|
| | 483 | | /// <summary> |
| | 484 | | /// Divide a <see cref="byte" /> by a <see cref="Byte2" />. |
| | 485 | | /// </summary> |
| | 486 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 487 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 488 | | /// <returns> |
| | 489 | | /// Returns the result of a division operation on a <see cref="byte" /> value and |
| | 490 | | /// <see cref="Byte2" />. |
| | 491 | | /// </returns> |
| | 492 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 493 | | public static Byte2 operator /(byte lhs, Byte2 rhs) |
| 0 | 494 | | { |
| 0 | 495 | | return new Byte2(lhs / rhs.X, lhs / rhs.Y); |
| 0 | 496 | | } |
| | 497 | |
|
| | 498 | | /// <summary> |
| | 499 | | /// Modulus a <see cref="Byte2" /> by another <see cref="Byte2" />. |
| | 500 | | /// </summary> |
| | 501 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 502 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 503 | | /// <returns>Returns the result of a modulus operation on two <see cref="Byte2" />.</returns> |
| | 504 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 505 | | public static Byte2 operator %(Byte2 lhs, Byte2 rhs) |
| 0 | 506 | | { |
| 0 | 507 | | return new Byte2(lhs.X % rhs.X, lhs.Y % rhs.Y); |
| 0 | 508 | | } |
| | 509 | |
|
| | 510 | | /// <summary> |
| | 511 | | /// Modulus a <see cref="Byte2" /> by a <see cref="byte" />. |
| | 512 | | /// </summary> |
| | 513 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 514 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 515 | | /// <returns> |
| | 516 | | /// Returns the result of a modulus operation on a <see cref="Byte2" /> and <see cref="byte" /> |
| | 517 | | /// value. |
| | 518 | | /// </returns> |
| | 519 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 520 | | public static Byte2 operator %(Byte2 lhs, byte rhs) |
| 0 | 521 | | { |
| 0 | 522 | | return new Byte2(lhs.X % rhs, lhs.Y % rhs); |
| 0 | 523 | | } |
| | 524 | |
|
| | 525 | | /// <summary> |
| | 526 | | /// Modulus a <see cref="byte" /> by a <see cref="Byte2" />. |
| | 527 | | /// </summary> |
| | 528 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 529 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 530 | | /// <returns> |
| | 531 | | /// Returns the result of a modulus operation on a <see cref="byte" /> value and |
| | 532 | | /// <see cref="Byte2" />. |
| | 533 | | /// </returns> |
| | 534 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 535 | | public static Byte2 operator %(byte lhs, Byte2 rhs) |
| 0 | 536 | | { |
| 0 | 537 | | return new Byte2(lhs % rhs.X, lhs % rhs.Y); |
| 0 | 538 | | } |
| | 539 | |
|
| | 540 | | /// <summary> |
| | 541 | | /// Increment <see cref="Byte2" /> values. |
| | 542 | | /// </summary> |
| | 543 | | /// <param name="val">Target <see cref="Byte2" />.</param> |
| | 544 | | /// <returns>Returns the result of an increment operation on a <see cref="Byte2" />.</returns> |
| | 545 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 546 | | public static Byte2 operator ++(Byte2 val) |
| 0 | 547 | | { |
| 0 | 548 | | return new Byte2(++val.X, ++val.Y); |
| 0 | 549 | | } |
| | 550 | |
|
| | 551 | | /// <summary> |
| | 552 | | /// Decrement <see cref="Byte2" /> values. |
| | 553 | | /// </summary> |
| | 554 | | /// <param name="val">Target <see cref="Byte2" />.</param> |
| | 555 | | /// <returns>Returns the result of a decrement operation on a <see cref="Byte2" />.</returns> |
| | 556 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 557 | | public static Byte2 operator --(Byte2 val) |
| 0 | 558 | | { |
| 0 | 559 | | return new Byte2(--val.X, --val.Y); |
| 0 | 560 | | } |
| | 561 | |
|
| | 562 | | /// <summary> |
| | 563 | | /// Unary minus <see cref="Byte2" /> values. |
| | 564 | | /// </summary> |
| | 565 | | /// <param name="val">Target <see cref="Byte2" />.</param> |
| | 566 | | /// <returns>Returns the result of an unary minus operation on a <see cref="Byte2" />.</returns> |
| | 567 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 568 | | public static Byte2 operator -(Byte2 val) |
| 0 | 569 | | { |
| 0 | 570 | | return new Byte2(-val.X, -val.Y); |
| 0 | 571 | | } |
| | 572 | |
|
| | 573 | | /// <summary> |
| | 574 | | /// Unary plus <see cref="Byte2" /> values. |
| | 575 | | /// </summary> |
| | 576 | | /// <param name="val">Target <see cref="Byte2" />.</param> |
| | 577 | | /// <returns>Returns the result of an unary plus operation on a <see cref="Byte2" />.</returns> |
| | 578 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 579 | | public static Byte2 operator +(Byte2 val) |
| 0 | 580 | | { |
| 0 | 581 | | return new Byte2(+val.X, +val.Y); |
| 0 | 582 | | } |
| | 583 | |
|
| | 584 | | /// <summary> |
| | 585 | | /// Bitwise NOT <see cref="Byte2" /> values. |
| | 586 | | /// </summary> |
| | 587 | | /// <param name="val">Target <see cref="Byte2" />.</param> |
| | 588 | | /// <returns>Returns the result of a bitwise NOT operation on a <see cref="Byte2" />.</returns> |
| | 589 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 590 | | public static Byte2 operator ~(Byte2 val) |
| 0 | 591 | | { |
| 0 | 592 | | return new Byte2(~val.X, ~val.Y); |
| 0 | 593 | | } |
| | 594 | |
|
| | 595 | | /// <summary> |
| | 596 | | /// Bitwise AND two <see cref="Byte2" /> values. |
| | 597 | | /// </summary> |
| | 598 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 599 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 600 | | /// <returns>Returns the result of a bitwise AND operation on two <see cref="Byte2" />.</returns> |
| | 601 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 602 | | public static Byte2 operator &(Byte2 lhs, Byte2 rhs) |
| 0 | 603 | | { |
| 0 | 604 | | return new Byte2(lhs.X & rhs.X, lhs.Y & rhs.Y); |
| 0 | 605 | | } |
| | 606 | |
|
| | 607 | | /// <summary> |
| | 608 | | /// Bitwise AND a <see cref="Byte2" /> and a <see cref="byte" />. |
| | 609 | | /// </summary> |
| | 610 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 611 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 612 | | /// <returns> |
| | 613 | | /// Returns the result of a bitwise AND operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 614 | | /// value. |
| | 615 | | /// </returns> |
| | 616 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 617 | | public static Byte2 operator &(Byte2 lhs, byte rhs) |
| 0 | 618 | | { |
| 0 | 619 | | return new Byte2(lhs.X & rhs, lhs.Y & rhs); |
| 0 | 620 | | } |
| | 621 | |
|
| | 622 | | /// <summary> |
| | 623 | | /// Bitwise AND a <see cref="byte" /> and a <see cref="Byte2" />. |
| | 624 | | /// </summary> |
| | 625 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 626 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 627 | | /// <returns> |
| | 628 | | /// Returns the result of a bitwise AND operation on a <see cref="byte" /> and a <see cref="Byte2" /> |
| | 629 | | /// value. |
| | 630 | | /// </returns> |
| | 631 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 632 | | public static Byte2 operator &(byte lhs, Byte2 rhs) |
| 0 | 633 | | { |
| 0 | 634 | | return new Byte2(lhs & rhs.X, lhs & rhs.Y); |
| 0 | 635 | | } |
| | 636 | |
|
| | 637 | | /// <summary> |
| | 638 | | /// Bitwise OR two <see cref="Byte2" /> values. |
| | 639 | | /// </summary> |
| | 640 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 641 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 642 | | /// <returns>Returns the result of a bitwise OR operation on two <see cref="Byte2" />.</returns> |
| | 643 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 644 | | public static Byte2 operator |(Byte2 lhs, Byte2 rhs) |
| 0 | 645 | | { |
| 0 | 646 | | return new Byte2(lhs.X | rhs.X, lhs.Y | rhs.Y); |
| 0 | 647 | | } |
| | 648 | |
|
| | 649 | | /// <summary> |
| | 650 | | /// Bitwise OR a <see cref="Byte2" /> and a <see cref="byte" />. |
| | 651 | | /// </summary> |
| | 652 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 653 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 654 | | /// <returns> |
| | 655 | | /// Returns the result of a bitwise OR operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 656 | | /// value. |
| | 657 | | /// </returns> |
| | 658 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 659 | | public static Byte2 operator |(Byte2 lhs, byte rhs) |
| 0 | 660 | | { |
| 0 | 661 | | return new Byte2(lhs.X | rhs, lhs.Y | rhs); |
| 0 | 662 | | } |
| | 663 | |
|
| | 664 | | /// <summary> |
| | 665 | | /// Bitwise OR a <see cref="byte" /> and a <see cref="Byte2" />. |
| | 666 | | /// </summary> |
| | 667 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 668 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 669 | | /// <returns> |
| | 670 | | /// Returns the result of a bitwise OR operation on a <see cref="byte" /> and a <see cref="Byte2" /> |
| | 671 | | /// value. |
| | 672 | | /// </returns> |
| | 673 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 674 | | public static Byte2 operator |(byte lhs, Byte2 rhs) |
| 0 | 675 | | { |
| 0 | 676 | | return new Byte2(lhs | rhs.X, lhs | rhs.Y); |
| 0 | 677 | | } |
| | 678 | |
|
| | 679 | | /// <summary> |
| | 680 | | /// Bitwise XOR two <see cref="Byte2" /> values. |
| | 681 | | /// </summary> |
| | 682 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 683 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 684 | | /// <returns>Returns the result of a bitwise EXCLUSIVE OR operation on two <see cref="Byte2" />.</returns> |
| | 685 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 686 | | public static Byte2 operator ^(Byte2 lhs, Byte2 rhs) |
| 0 | 687 | | { |
| 0 | 688 | | return new Byte2(lhs.X ^ rhs.X, lhs.Y ^ rhs.Y); |
| 0 | 689 | | } |
| | 690 | |
|
| | 691 | | /// <summary> |
| | 692 | | /// Bitwise XOR a <see cref="Byte2" /> and a <see cref="byte" />. |
| | 693 | | /// </summary> |
| | 694 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 695 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 696 | | /// <returns> |
| | 697 | | /// Returns the result of a bitwise XOR operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 698 | | /// value. |
| | 699 | | /// </returns> |
| | 700 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 701 | | public static Byte2 operator ^(Byte2 lhs, byte rhs) |
| 0 | 702 | | { |
| 0 | 703 | | return new Byte2(lhs.X ^ rhs, lhs.Y ^ rhs); |
| 0 | 704 | | } |
| | 705 | |
|
| | 706 | | /// <summary> |
| | 707 | | /// Bitwise XOR a <see cref="byte" /> and a <see cref="Byte2" />. |
| | 708 | | /// </summary> |
| | 709 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 710 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 711 | | /// <returns> |
| | 712 | | /// Returns the result of a bitwise XOR operation on a <see cref="byte" /> and a <see cref="Byte2" /> |
| | 713 | | /// value. |
| | 714 | | /// </returns> |
| | 715 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 716 | | public static Byte2 operator ^(byte lhs, Byte2 rhs) |
| 0 | 717 | | { |
| 0 | 718 | | return new Byte2(lhs ^ rhs.X, lhs ^ rhs.Y); |
| 0 | 719 | | } |
| | 720 | |
|
| | 721 | | /// <summary> |
| | 722 | | /// Get a hash code from the <see cref="Byte2" />. |
| | 723 | | /// </summary> |
| | 724 | | /// <remarks> |
| | 725 | | /// This loosely based on the Fowler–Noll–Vo (FNV) hash function. |
| | 726 | | /// </remarks> |
| | 727 | | /// <returns>A <see cref="int" /> value.</returns> |
| | 728 | | public override int GetHashCode() |
| 0 | 729 | | { |
| | 730 | | unchecked |
| 0 | 731 | | { |
| | 732 | | const int k_P = 16777619; |
| 0 | 733 | | int hash = (int)2166136261; |
| | 734 | |
|
| 0 | 735 | | hash = (hash ^ X) * k_P; |
| 0 | 736 | | hash = (hash ^ Y) * k_P; |
| | 737 | |
|
| 0 | 738 | | hash += hash << 13; |
| 0 | 739 | | hash ^= hash >> 7; |
| 0 | 740 | | hash += hash << 3; |
| 0 | 741 | | hash ^= hash >> 17; |
| 0 | 742 | | hash += hash << 5; |
| | 743 | |
|
| 0 | 744 | | return hash; |
| | 745 | | } |
| 0 | 746 | | } |
| | 747 | |
|
| | 748 | | /// <summary> |
| | 749 | | /// Returns a <see cref="string" /> representation of the <see cref="Byte2" />. |
| | 750 | | /// </summary> |
| | 751 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 752 | | public override string ToString() |
| 1 | 753 | | { |
| 1 | 754 | | return $"Byte2({X.ToString()},{Y.ToString()})"; |
| 1 | 755 | | } |
| | 756 | |
|
| | 757 | | /// <summary> |
| | 758 | | /// Explicitly converts a <see cref="Unity.Mathematics.bool2" /> to a <see cref="Byte2" /> by conversion. |
| | 759 | | /// </summary> |
| | 760 | | /// <param name="v">The value to transcribe.</param> |
| | 761 | | /// <returns>A new <see cref="Byte2" /> created from <paramref name="v" />.</returns> |
| | 762 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 763 | | public static explicit operator Byte2(bool2 v) |
| 1 | 764 | | { |
| 1 | 765 | | return new Byte2(v); |
| 1 | 766 | | } |
| | 767 | |
|
| | 768 | | /// <summary> |
| | 769 | | /// Explicitly converts a <see cref="Unity.Mathematics.bool2" /> to a <see cref="Byte2" /> by conversion. |
| | 770 | | /// </summary> |
| | 771 | | /// <param name="v">The value to transcribe.</param> |
| | 772 | | /// <returns>A new <see cref="Byte2" /> created from <paramref name="v" />.</returns> |
| | 773 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 774 | | public static explicit operator Byte2(float2 v) |
| 1 | 775 | | { |
| 1 | 776 | | return new Byte2(v); |
| 1 | 777 | | } |
| | 778 | |
|
| | 779 | | /// <summary> |
| | 780 | | /// Explicitly converts a <see cref="Unity.Mathematics.double2" /> to a <see cref="Byte2" /> by |
| | 781 | | /// conversion. |
| | 782 | | /// </summary> |
| | 783 | | /// <param name="v">The value to transcribe.</param> |
| | 784 | | /// <returns>A new <see cref="Byte2" /> created from <paramref name="v" />.</returns> |
| | 785 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 786 | | public static explicit operator Byte2(double2 v) |
| 1 | 787 | | { |
| 1 | 788 | | return new Byte2(v); |
| 1 | 789 | | } |
| | 790 | |
|
| | 791 | | /// <summary> |
| | 792 | | /// Determine if one <see cref="Byte2" /> is less than another <see cref="Byte2" />. |
| | 793 | | /// </summary> |
| | 794 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 795 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 796 | | /// <returns>Returns the result of a LESS THAN operation on two <see cref="Byte2" />.</returns> |
| | 797 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 798 | | public static bool2 operator <(Byte2 lhs, Byte2 rhs) |
| 0 | 799 | | { |
| 0 | 800 | | return new bool2(lhs.X < rhs.X, lhs.Y < rhs.Y); |
| 0 | 801 | | } |
| | 802 | |
|
| | 803 | | /// <summary> |
| | 804 | | /// Determine if <see cref="Byte2" /> is less than a <see cref="byte" />. |
| | 805 | | /// </summary> |
| | 806 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 807 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 808 | | /// <returns> |
| | 809 | | /// Returns the result of a LESS THAN operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 810 | | /// value. |
| | 811 | | /// </returns> |
| | 812 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 813 | | public static bool2 operator <(Byte2 lhs, byte rhs) |
| 0 | 814 | | { |
| 0 | 815 | | return new bool2(lhs.X < rhs, lhs.Y < rhs); |
| 0 | 816 | | } |
| | 817 | |
|
| | 818 | | /// <summary> |
| | 819 | | /// Determine if <see cref="byte" /> is less than a <see cref="Byte2" />. |
| | 820 | | /// </summary> |
| | 821 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 822 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 823 | | /// <returns> |
| | 824 | | /// Returns the result of a LESS THAN operation on a <see cref="byte" /> and a <see cref="Byte2" /> |
| | 825 | | /// value. |
| | 826 | | /// </returns> |
| | 827 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 828 | | public static bool2 operator <(byte lhs, Byte2 rhs) |
| 0 | 829 | | { |
| 0 | 830 | | return new bool2(lhs < rhs.X, lhs < rhs.Y); |
| 0 | 831 | | } |
| | 832 | |
|
| | 833 | | /// <summary> |
| | 834 | | /// Determine if one <see cref="Byte2" /> is less than or equal to another <see cref="Byte2" />. |
| | 835 | | /// </summary> |
| | 836 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 837 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 838 | | /// <returns>Returns the result of a LESS THAN OR EQUAL operation on two <see cref="Byte2" />.</returns> |
| | 839 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 840 | | public static bool2 operator <=(Byte2 lhs, Byte2 rhs) |
| 0 | 841 | | { |
| 0 | 842 | | return new bool2(lhs.X <= rhs.X, lhs.Y <= rhs.Y); |
| 0 | 843 | | } |
| | 844 | |
|
| | 845 | | /// <summary> |
| | 846 | | /// Determine if <see cref="Byte2 " /> is less than or equal a <see cref="byte" />. |
| | 847 | | /// </summary> |
| | 848 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 849 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 850 | | /// <returns> |
| | 851 | | /// Returns the result of a LESS THAN OR EQUAL operation on a <see cref="Byte2" /> and a |
| | 852 | | /// <see cref="byte" /> |
| | 853 | | /// value. |
| | 854 | | /// </returns> |
| | 855 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 856 | | public static bool2 operator <=(Byte2 lhs, byte rhs) |
| 0 | 857 | | { |
| 0 | 858 | | return new bool2(lhs.X <= rhs, lhs.Y <= rhs); |
| 0 | 859 | | } |
| | 860 | |
|
| | 861 | | /// <summary> |
| | 862 | | /// Determine if <see cref="byte" /> is less than or equal a <see cref="Byte2" />. |
| | 863 | | /// </summary> |
| | 864 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 865 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 866 | | /// <returns> |
| | 867 | | /// Returns the result of a LESS THAN OR EQUAL operation on a <see cref="byte" /> and a |
| | 868 | | /// <see cref="Byte2" /> |
| | 869 | | /// value. |
| | 870 | | /// </returns> |
| | 871 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 872 | | public static bool2 operator <=(byte lhs, Byte2 rhs) |
| 0 | 873 | | { |
| 0 | 874 | | return new bool2(lhs <= rhs.X, lhs <= rhs.Y); |
| 0 | 875 | | } |
| | 876 | |
|
| | 877 | | /// <summary> |
| | 878 | | /// Determine if one <see cref="Byte2" /> is less than another <see cref="Byte2" />. |
| | 879 | | /// </summary> |
| | 880 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 881 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 882 | | /// <returns>Returns the result of a LESS THAN operation on two <see cref="Byte2" />.</returns> |
| | 883 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 884 | | public static bool2 operator >(Byte2 lhs, Byte2 rhs) |
| 0 | 885 | | { |
| 0 | 886 | | return new bool2(lhs.X > rhs.X, lhs.Y > rhs.Y); |
| 0 | 887 | | } |
| | 888 | |
|
| | 889 | | /// <summary> |
| | 890 | | /// Determine if <see cref="Byte2 " /> is greater than a <see cref="byte" />. |
| | 891 | | /// </summary> |
| | 892 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 893 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 894 | | /// <returns> |
| | 895 | | /// Returns the result of a GREATER THAN operation on a <see cref="Byte2" /> and a <see cref="byte" /> |
| | 896 | | /// value. |
| | 897 | | /// </returns> |
| | 898 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 899 | | public static bool2 operator >(Byte2 lhs, byte rhs) |
| 0 | 900 | | { |
| 0 | 901 | | return new bool2(lhs.X > rhs, lhs.Y > rhs); |
| 0 | 902 | | } |
| | 903 | |
|
| | 904 | | /// <summary> |
| | 905 | | /// Determine if <see cref="byte" /> is greater than a <see cref="Byte2" />. |
| | 906 | | /// </summary> |
| | 907 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 908 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 909 | | /// <returns> |
| | 910 | | /// Returns the result of a GREATER THAN operation on a <see cref="byte" /> and a <see cref="Byte2" /> |
| | 911 | | /// value. |
| | 912 | | /// </returns> |
| | 913 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 914 | | public static bool2 operator >(byte lhs, Byte2 rhs) |
| 0 | 915 | | { |
| 0 | 916 | | return new bool2(lhs > rhs.X, lhs > rhs.Y); |
| 0 | 917 | | } |
| | 918 | |
|
| | 919 | |
|
| | 920 | | /// <summary> |
| | 921 | | /// Determine if <see cref="Byte2 " /> is greater than or equal a <see cref="Byte2" />. |
| | 922 | | /// </summary> |
| | 923 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 924 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 925 | | /// <returns> |
| | 926 | | /// Returns the result of a GREATER THAN OR EQUAL operation on a <see cref="Byte2" /> and a |
| | 927 | | /// <see cref="Byte2" /> |
| | 928 | | /// value. |
| | 929 | | /// </returns> |
| | 930 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 931 | | public static bool2 operator >=(Byte2 lhs, Byte2 rhs) |
| 0 | 932 | | { |
| 0 | 933 | | return new bool2(lhs.X >= rhs.X, lhs.Y >= rhs.Y); |
| 0 | 934 | | } |
| | 935 | |
|
| | 936 | | /// <summary> |
| | 937 | | /// Determine if <see cref="Byte2 " /> is greater than or equal a <see cref="byte" />. |
| | 938 | | /// </summary> |
| | 939 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 940 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 941 | | /// <returns> |
| | 942 | | /// Returns the result of a GREATER THAN OR EQUAL operation on a <see cref="Byte2" /> and a |
| | 943 | | /// <see cref="byte" /> |
| | 944 | | /// value. |
| | 945 | | /// </returns> |
| | 946 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 947 | | public static bool2 operator >=(Byte2 lhs, byte rhs) |
| 0 | 948 | | { |
| 0 | 949 | | return new bool2(lhs.X >= rhs, lhs.Y >= rhs); |
| 0 | 950 | | } |
| | 951 | |
|
| | 952 | | /// <summary> |
| | 953 | | /// Determine if <see cref="byte " /> is greater than or equal a <see cref="Byte2" />. |
| | 954 | | /// </summary> |
| | 955 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 956 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 957 | | /// <returns> |
| | 958 | | /// Returns the result of a GREATER THAN OR EQUAL operation on a <see cref="byte" /> and a |
| | 959 | | /// <see cref="Byte2" /> |
| | 960 | | /// value. |
| | 961 | | /// </returns> |
| | 962 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 963 | | public static bool2 operator >=(byte lhs, Byte2 rhs) |
| 0 | 964 | | { |
| 0 | 965 | | return new bool2(lhs >= rhs.X, lhs >= rhs.Y); |
| 0 | 966 | | } |
| | 967 | |
|
| | 968 | | /// <summary> |
| | 969 | | /// Determine if one <see cref="Byte2" /> is equal to another <see cref="Byte2" />. |
| | 970 | | /// </summary> |
| | 971 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 972 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 973 | | /// <returns>Returns the result of an EQUALITY operation on two <see cref="Byte2" />.</returns> |
| | 974 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 975 | | public static bool2 operator ==(Byte2 lhs, Byte2 rhs) |
| 0 | 976 | | { |
| 0 | 977 | | return new bool2(lhs.X == rhs.X, lhs.Y == rhs.Y); |
| 0 | 978 | | } |
| | 979 | |
|
| | 980 | | /// <summary> |
| | 981 | | /// Determine if both components of a <see cref="Byte2" /> are equal to a <see cref="byte" />. |
| | 982 | | /// </summary> |
| | 983 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 984 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 985 | | /// <returns>Returns the result of an EQUALITY operation on a <see cref="Byte2" /> and a <see cref="byte" />.</r |
| | 986 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 987 | | public static bool2 operator ==(Byte2 lhs, byte rhs) |
| 0 | 988 | | { |
| 0 | 989 | | return new bool2(lhs.X == rhs, lhs.Y == rhs); |
| 0 | 990 | | } |
| | 991 | |
|
| | 992 | | /// <summary> |
| | 993 | | /// Determine if both components of a <see cref="Byte2" /> are equal to a <see cref="byte" />. |
| | 994 | | /// </summary> |
| | 995 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 996 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 997 | | /// <returns>Returns the result of an EQUALITY operation on a <see cref="byte" /> and a <see cref="Byte2" />.</r |
| | 998 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 999 | | public static bool2 operator ==(byte lhs, Byte2 rhs) |
| 0 | 1000 | | { |
| 0 | 1001 | | return new bool2(lhs == rhs.X, lhs == rhs.Y); |
| 0 | 1002 | | } |
| | 1003 | |
|
| | 1004 | | /// <summary> |
| | 1005 | | /// Determine if one <see cref="Byte2" /> is not equal to another <see cref="Byte2" />. |
| | 1006 | | /// </summary> |
| | 1007 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 1008 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 1009 | | /// <returns>Returns the result of a NOT EQUAL operation on two <see cref="Byte2" />.</returns> |
| | 1010 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 1011 | | public static bool2 operator !=(Byte2 lhs, Byte2 rhs) |
| 0 | 1012 | | { |
| 0 | 1013 | | return new bool2(lhs.X != rhs.X, lhs.Y != rhs.Y); |
| 0 | 1014 | | } |
| | 1015 | |
|
| | 1016 | | /// <summary> |
| | 1017 | | /// Determine if both components of a <see cref="Byte2" /> are not equal to a <see cref="byte" />. |
| | 1018 | | /// </summary> |
| | 1019 | | /// <param name="lhs">Left-hand side <see cref="Byte2" />.</param> |
| | 1020 | | /// <param name="rhs">Right-hand side <see cref="byte" />.</param> |
| | 1021 | | /// <returns>Returns the result of a NOT EQUAL operation on a <see cref="Byte2" /> and a <see cref="byte" />.</r |
| | 1022 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 1023 | | public static bool2 operator !=(Byte2 lhs, byte rhs) |
| 0 | 1024 | | { |
| 0 | 1025 | | return new bool2(lhs.X != rhs, lhs.Y != rhs); |
| 0 | 1026 | | } |
| | 1027 | |
|
| | 1028 | | /// <summary> |
| | 1029 | | /// Determine if both components of a <see cref="Byte2" /> are not equal to a <see cref="byte" />. |
| | 1030 | | /// </summary> |
| | 1031 | | /// <param name="lhs">Left-hand side <see cref="byte" />.</param> |
| | 1032 | | /// <param name="rhs">Right-hand side <see cref="Byte2" />.</param> |
| | 1033 | | /// <returns>Returns the result of a NOT EQUAL operation on a <see cref="byte" /> and a <see cref="Byte2" />.</r |
| | 1034 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 1035 | | public static bool2 operator !=(byte lhs, Byte2 rhs) |
| 0 | 1036 | | { |
| 0 | 1037 | | return new bool2(lhs != rhs.X, lhs != rhs.Y); |
| 0 | 1038 | | } |
| | 1039 | |
|
| | 1040 | | /// <summary> |
| | 1041 | | /// Debug object used by IDEs for visibility of a <see cref="Byte2" />. |
| | 1042 | | /// </summary> |
| | 1043 | | internal sealed class DebuggerProxy |
| | 1044 | | { |
| | 1045 | | /// <summary> |
| | 1046 | | /// X <see cref="byte" />. |
| | 1047 | | /// </summary> |
| | 1048 | | public byte X; |
| | 1049 | |
|
| | 1050 | | /// <summary> |
| | 1051 | | /// Y <see cref="byte" />. |
| | 1052 | | /// </summary> |
| | 1053 | | public byte Y; |
| | 1054 | |
|
| 0 | 1055 | | public DebuggerProxy(Byte2 v) |
| 0 | 1056 | | { |
| 0 | 1057 | | X = v.X; |
| 0 | 1058 | | Y = v.Y; |
| 0 | 1059 | | } |
| | 1060 | | } |
| | 1061 | | } |
| | 1062 | | } |