FillPair.cs 1.3 KB

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