mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Disabled Hover (#define HOVER).
Added Color.GetHighlightColor. Simple implementation for now. Needs to be more robust.
This commit is contained in:
@@ -6,6 +6,7 @@ using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json.Serialization;
|
||||
using ColorHelper;
|
||||
|
||||
namespace Terminal.Gui;
|
||||
|
||||
@@ -237,6 +238,27 @@ public readonly partial record struct Color : ISpanParsable<Color>, IUtf8SpanPar
|
||||
[SkipLocalsInit]
|
||||
private static float CalculateColorDistance (in Vector4 color1, in Vector4 color2) { return Vector4.Distance (color1, color2); }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a color that is the same hue as the current color, but with a different lightness.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Color GetHighlightColor ()
|
||||
{
|
||||
// TODO: This is a temporary implementation; just enough to show how it could work.
|
||||
var hsl = ColorHelper.ColorConverter.RgbToHsl(new RGB (R, G, B));
|
||||
|
||||
var amount = .7;
|
||||
if (hsl.L < 50)
|
||||
{
|
||||
amount += 1;
|
||||
}
|
||||
hsl.L = (byte)(hsl.L * amount);
|
||||
|
||||
var rgb = ColorHelper.ColorConverter.HslToRgb (hsl);
|
||||
return new (rgb.R, rgb.G, rgb.B);
|
||||
|
||||
}
|
||||
|
||||
#region Legacy Color Names
|
||||
|
||||
/// <summary>The black color.</summary>
|
||||
|
||||
Reference in New Issue
Block a user