BBar.cs 619 B

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