Knot3.Game.Data.KnotStringIO.DecodeColor C# (CSharp) Méthode

DecodeColor() private static méthode

private static DecodeColor ( string hexString ) : Color
hexString string
Résultat Color
        private static Color DecodeColor(string hexString)
        {
            if (hexString.StartsWith ("#")) {
                hexString = hexString.Substring (1);
            }

            uint hex = unchecked ( uint.Parse (hexString, System.Globalization.NumberStyles.HexNumber) );
            Color color = Color.White;
            if (hexString.Length == 8) {
                unchecked {
                    color.R = (byte)(hex >> 24);
                    color.G = (byte)(hex >> 16);
                    color.B = (byte)(hex >> 8);
                    color.A = (byte)(hex);
                }
            }
            else if (hexString.Length == 6) {
                unchecked {
                    color.R = (byte)(hex >> 16);
                    color.G = (byte)(hex >> 8);
                    color.B = (byte)(hex);
                }
            }
            else {
                throw new IOException ("Invalid hex representation of an ARGB or RGB color value.");
            }
            return color;
        }