/// <summary> /// Initializes a new instance of the <see cref="RGBA"/> structure. /// </summary> /// <param name="color">An <see cref="RGB"/> color.</param> /// <param name="alpha">The alpha channel component.</param> public RGBA(RGB color, double alpha) : this(color.Red, color.Green, color.Blue, alpha) { }
/// <summary> /// Gets the luminance of the specified color. /// </summary> /// <param name="color">The color.</param> /// <returns>The luminance value of the color.</returns> public static double Luminance(this RGB color) { return(Luminance(color.Red, color.Green, color.Blue)); }
/// <summary> /// Initializes a new instance of the <see cref="RGBA"/> structure. /// </summary> /// <param name="color">An <see cref="RGB"/> color.</param> public RGBA(RGB color) : this(color.Red, color.Green, color.Blue, 1) { }
/// <summary> /// Gets the best foreground color given the specified background color. /// </summary> /// <param name="color">The background color.</param> /// <returns>The best <see cref="RGB"/> foreground color.</returns> public static RGB GetBestForegroundColor(this RGB color) { return(color.Luminance() > rgbThreshold ? RGB.Black : RGB.White); }