FillPair.cs 1.3 KB

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