Exemple #1
0
        ////https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
        public static double LuminanceRatio(Color c1, Color c2)
        {
            //(L1 + 0.05) / (L2 + 0.05)

            Color L1, L2;

            if (c1.GetBrightness() > c2.GetBrightness())
            {
                L1 = c1;
                L2 = c2;
            }
            else
            {
                L1 = c2;
                L2 = c1;
            }

            double ratio = (L1.LuminanceValue() + 0.05) / (L2.LuminanceValue() + 0.05);

            return(Math.Min(ratio, 21));
        }