Files
CMLeonOS/Gui/UILib/Extensions.cs

18 lines
440 B
C#
Raw Normal View History

2026-03-01 17:03:49 +08:00
using System.Drawing;
namespace CMLeonOS.Gui.UILib
{
internal static class Extensions
{
internal static float GetLuminance(this Color color)
{
return (float)((color.R * 0.2126) + (color.G * 0.7152) + (color.B * 0.0722));
}
internal static Color GetForegroundColour(this Color color)
{
return color.GetLuminance() < 140 ? Color.White : Color.Black;
}
}
}