示例#1
0
 public static RGBA GetBestForegroundColor(this RGBA color)
 {
     return(color.Luminance() > rgbThreshold ? RGBA.Black : RGBA.White);
     //return (color.Red * 0.299 + color.Green * 0.587 + color.Blue * 0.114 > 160) ? RGBA.White : RGBA.Black;
 }
示例#2
0
 public static double Luminance(this RGBA color)
 {
     return(Luminance(color.Red, color.Green, color.Blue));
 }
示例#3
0
 /// <summary>
 /// Gets the best foreground color given the specified background color.
 /// </summary>
 /// <param name="color">The background color.</param>
 /// <returns>The best <see cref="RGBA"/> foreground color.</returns>
 public static RGBA GetBestForegroundColor(this RGBA color)
 {
     return(color.Luminance() > rgbThreshold ? RGBA.Black : RGBA.White);
 }