FillPair.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// Describes a pair of <see cref="IFill"/> which cooperate in creating
  4. /// <see cref="Attribute"/>. One gives foreground color while other gives background.
  5. /// </summary>
  6. public class FillPair
  7. {
  8. /// <summary>
  9. /// Creates a new instance using the provided fills for foreground and background
  10. /// color when assembling <see cref="Attribute"/>.
  11. /// </summary>
  12. /// <param name="fore"></param>
  13. /// <param name="back"></param>
  14. public FillPair (IFill fore, IFill back)
  15. {
  16. Foreground = fore;
  17. Background = back;
  18. }
  19. /// <summary>
  20. /// The fill which provides point based foreground color.
  21. /// </summary>
  22. public IFill Foreground { get; init; }
  23. /// <summary>
  24. /// The fill which provides point based background color.
  25. /// </summary>
  26. public IFill Background { get; init; }
  27. /// <summary>
  28. /// Returns the color pair (foreground+background) to use when rendering
  29. /// a rune at the given <paramref name="point"/>.
  30. /// </summary>
  31. /// <param name="point"></param>
  32. /// <returns></returns>
  33. public Attribute GetAttribute (Point point)
  34. {
  35. return new (Foreground.GetColor (point), Background.GetColor (point));
  36. }
  37. }