Exemple #1
0
        // http://www.easyrgb.com/en/math.php
        private static Xyz ToXyz(Rgb color)
        {
            var num1 = PivotRgb(color.R / (double)byte.MaxValue);
            var num2 = PivotRgb(color.G / (double)byte.MaxValue);
            var num3 = PivotRgb(color.B / (double)byte.MaxValue);
            var x    = num1 * 0.4124 + num2 * 0.3576 + num3 * 0.1805;
            var y    = num1 * 0.2126 + num2 * (447.0 / 625.0) + num3 * 0.0722;
            var z    = num1 * 0.0193 + num2 * 0.1192 + num3 * 0.9505;

            return(new Xyz {
                X = x, Y = y, Z = z
            });
        }
Exemple #2
0
 public static string ToHex(Rgb rgb)
 {
     return(rgb.R.ToString("X2") + rgb.G.ToString("X2") + rgb.B.ToString("X2"));
 }
Exemple #3
0
        public ServerColor(int color)
        {
            var hexValue = color.ToString("X6");

            Rgb = ToRgb(hexValue);
        }
Exemple #4
0
 public ServerColor(string hex)
 {
     Rgb = ToRgb(hex);
 }
Exemple #5
0
 public ServerColor(Rgb rgb)
 {
     Rgb = rgb;
 }