mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-13 03:34:55 +08:00
23 lines
613 B
C#
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));
|
|
}
|
|
}
|
|
} |