Scanline.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. namespace PaintDotNet
  2. {
  3. public struct Scanline
  4. {
  5. private int x;
  6. private int y;
  7. private int length;
  8. public int X
  9. {
  10. get
  11. {
  12. return x;
  13. }
  14. }
  15. public int Y
  16. {
  17. get
  18. {
  19. return y;
  20. }
  21. }
  22. public int Length
  23. {
  24. get
  25. {
  26. return length;
  27. }
  28. }
  29. public override int GetHashCode()
  30. {
  31. unchecked
  32. {
  33. return length.GetHashCode() + x.GetHashCode() + y.GetHashCode();
  34. }
  35. }
  36. public override bool Equals(object obj)
  37. {
  38. if (obj is Scanline)
  39. {
  40. Scanline rhs = (Scanline)obj;
  41. return x == rhs.x && y == rhs.y && length == rhs.length;
  42. }
  43. else
  44. {
  45. return false;
  46. }
  47. }
  48. public static bool operator ==(Scanline lhs, Scanline rhs)
  49. {
  50. return lhs.x == rhs.x && lhs.y == rhs.y && lhs.length == rhs.length;
  51. }
  52. public static bool operator !=(Scanline lhs, Scanline rhs)
  53. {
  54. return !(lhs == rhs);
  55. }
  56. public override string ToString()
  57. {
  58. return "(" + x + "," + y + "):[" + length.ToString() + "]";
  59. }
  60. public Scanline(int x, int y, int length)
  61. {
  62. this.x = x;
  63. this.y = y;
  64. this.length = length;
  65. }
  66. }
  67. }