ScreenLayout.cs 888 B

12345678910111213141516171819
  1. using System;
  2. namespace DevilLink2.UI
  3. {
  4. public static class ScreenLayout
  5. {
  6. public const float Width = 430, Height = 932;
  7. public const float HudHeight = 56, DockReserve = 82, CardGap = 8, CardInset = 12;
  8. public const float CardHeight = (Height - HudHeight - DockReserve - 20 - CardGap * 2) / 3;
  9. public static float CardTop(int index)
  10. { if (index < 0 || index > 2) throw new ArgumentOutOfRangeException(nameof(index)); return HudHeight + 10 + index * (CardHeight + CardGap); }
  11. public static float FitScale(float width, float height)
  12. {
  13. if (float.IsNaN(width) || float.IsNaN(height) || float.IsInfinity(width) || float.IsInfinity(height) || width < 0 || height < 0)
  14. throw new ArgumentOutOfRangeException(nameof(width));
  15. return Math.Min(width / Width, height / Height);
  16. }
  17. }
  18. }