HueBar.cs 572 B

12345678910111213141516171819202122
  1. using ColorHelper;
  2. using ColorConverter = ColorHelper.ColorConverter;
  3. namespace Terminal.Gui.Views;
  4. /// <summary>
  5. /// A bar representing the Hue component of a <see cref="Color"/> in HSL color space.
  6. /// </summary>
  7. internal class HueBar : ColorBar
  8. {
  9. /// <inheritdoc/>
  10. protected override Color GetColor (double fraction)
  11. {
  12. var hsl = new HSL ((int)(MaxValue * fraction), 100, 50);
  13. RGB rgb = ColorConverter.HslToRgb (hsl);
  14. return new (rgb.R, rgb.G, rgb.B);
  15. }
  16. /// <inheritdoc/>
  17. protected override int MaxValue => 360;
  18. }