ValueBar.cs 719 B

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