]> O.S.I.I.S - jp/crow.git/commitdiff
color conversion debug
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 14 Mar 2021 01:03:46 +0000 (02:03 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 14 Mar 2021 01:03:46 +0000 (02:03 +0100)
Crow/src/Colors.cs

index 5b4396f71f169947dec50534f139687ca6cc6f9e..ba2ad7e8dae2c6b7268e146c41dd55a017dcab69 100644 (file)
@@ -352,7 +352,9 @@ namespace Crow
 
                public static Color Parse(string s)
                        => string.IsNullOrEmpty (s) ? new Color (Colors.White) :
-                               s[0] == '#' ? new Color (UInt32.Parse (s.AsSpan().Slice (1), System.Globalization.NumberStyles.HexNumber)) :
+                               s[0] == '#' ? s.Length < 8 ?
+                               new Color (0xff + (UInt32.Parse (s.AsSpan ().Slice (1), System.Globalization.NumberStyles.HexNumber)<<8))
+                               : new Color (UInt32.Parse (s.AsSpan().Slice (1), System.Globalization.NumberStyles.HexNumber)) :
                                char.IsDigit(s[0]) ? FromIml (s) :
                                FastEnum.TryParse<Colors> (s, out Colors cc) ? new Color(cc) :
                                throw new Exception ("Unknown color name: " + s);