RBar.cs 606 B

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