Size.cs 957 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. namespace QuestPDF.Infrastructure
  3. {
  4. public readonly struct Size
  5. {
  6. public const float Epsilon = 0.001f;
  7. public const float Infinity = 14_400;
  8. public readonly float Width;
  9. public readonly float Height;
  10. public static Size Zero { get; } = new Size(0, 0);
  11. public static Size Max { get; } = new Size(Infinity, Infinity);
  12. public Size(float width, float height)
  13. {
  14. Width = width;
  15. Height = height;
  16. }
  17. internal static bool Equal(Size first, Size second)
  18. {
  19. if (Math.Abs(first.Width - second.Width) > Size.Epsilon)
  20. return false;
  21. if (Math.Abs(first.Height - second.Height) > Size.Epsilon)
  22. return false;
  23. return true;
  24. }
  25. public override string ToString() => $"(Width: {Width:N3}, Height: {Height:N3})";
  26. }
  27. }