RBar.cs 619 B

123456789101112131415161718192021222324252627
  1. #nullable enable
  2. using ColorHelper;
  3. namespace Terminal.Gui;
  4. internal class RBar : ColorBar
  5. {
  6. public BBar? BBar { get; set; }
  7. public GBar? GBar { get; set; }
  8. /// <inheritdoc/>
  9. protected override Color GetColor (double fraction)
  10. {
  11. if (GBar == null || BBar == null)
  12. {
  13. throw new ($"{nameof (RBar)} has not been set up correctly before drawing");
  14. }
  15. var rgb = new RGB ((byte)(MaxValue * fraction), (byte)GBar.Value, (byte)BBar.Value);
  16. return new (rgb.R, rgb.G, rgb.B);
  17. }
  18. /// <inheritdoc/>
  19. protected override int MaxValue => 255;
  20. }