Files
BetterLyrics/ColorThief.WinUI3/QuantizedColor.cs
2025-10-23 22:38:31 +08:00

23 lines
613 B
C#

using System;
namespace ColorThiefDotNet
{
public class QuantizedColor
{
public QuantizedColor(Color color, int population)
{
Color = color;
Population = population;
IsDark = CalculateYiqLuma(color) < 128;
}
public Color Color { get; private set; }
public int Population { get; private set; }
public bool IsDark { get; private set; }
public int CalculateYiqLuma(Color color)
{
return Convert.ToInt32(Math.Round((299 * color.R + 587 * color.G + 114 * color.B) / 1000f));
}
}
}