Rect2.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. namespace BansheeEngine
  7. {
  8. [StructLayout(LayoutKind.Sequential)]
  9. public class Rect2
  10. {
  11. public Rect2(float x, float y, float width, float height)
  12. {
  13. this.x = x;
  14. this.y = y;
  15. this.width = width;
  16. this.height = height;
  17. }
  18. public static bool operator ==(Rect2 lhs, Rect2 rhs)
  19. {
  20. return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height;
  21. }
  22. public static bool operator !=(Rect2 lhs, Rect2 rhs)
  23. {
  24. return !(lhs == rhs);
  25. }
  26. public override bool Equals(object other)
  27. {
  28. if (!(other is Rect2))
  29. return false;
  30. Rect2 rect = (Rect2)other;
  31. if (x.Equals(rect.x) && y.Equals(rect.y) && width.Equals(rect.width) && height.Equals(rect.height))
  32. return true;
  33. return false;
  34. }
  35. public override int GetHashCode()
  36. {
  37. return base.GetHashCode();
  38. }
  39. public float x, y, width, height;
  40. }
  41. }