mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-03-03 15:30:27 +00:00
18 lines
440 B
C#
18 lines
440 B
C#
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;
|
|
}
|
|
}
|
|
}
|