mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-10-31 17:15:28 +08:00 
			
		
		
		
	Add color aliases
This commit is contained in:
		| @@ -132,7 +132,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 50 | ||||
|     }, | ||||
|     "name": "Grey" | ||||
|     "name": "Grey", | ||||
|     "aliases": [ "Gray" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 9, | ||||
| @@ -207,7 +208,8 @@ | ||||
|       "s": 100, | ||||
|       "l": 50 | ||||
|     }, | ||||
|     "name": "Fuchsia" | ||||
|     "name": "Fuchsia", | ||||
|     "aliases": [ "Magenta" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 14, | ||||
| @@ -222,7 +224,8 @@ | ||||
|       "s": 100, | ||||
|       "l": 50 | ||||
|     }, | ||||
|     "name": "Aqua" | ||||
|     "name": "Aqua", | ||||
|     "aliases": [ "Cyan" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 15, | ||||
| @@ -252,7 +255,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 0 | ||||
|     }, | ||||
|     "name": "Grey0" | ||||
|     "name": "Grey0", | ||||
|     "aliases": [ "Gray0" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 17, | ||||
| @@ -897,7 +901,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 37 | ||||
|     }, | ||||
|     "name": "Grey37" | ||||
|     "name": "Grey37", | ||||
|     "aliases": [ "Gray37" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 60, | ||||
| @@ -1542,7 +1547,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 52 | ||||
|     }, | ||||
|     "name": "Grey53" | ||||
|     "name": "Grey53", | ||||
|     "aliases": [ "Gray53" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 103, | ||||
| @@ -2097,7 +2103,8 @@ | ||||
|       "s": 20, | ||||
|       "l": 60 | ||||
|     }, | ||||
|     "name": "Grey63" | ||||
|     "name": "Grey63", | ||||
|     "aliases": [ "Gray63" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 140, | ||||
| @@ -2187,7 +2194,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 68 | ||||
|     }, | ||||
|     "name": "Grey69" | ||||
|     "name": "Grey69", | ||||
|     "aliases": [ "Gray69" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 146, | ||||
| @@ -2832,7 +2840,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 84 | ||||
|     }, | ||||
|     "name": "Grey84" | ||||
|     "name": "Grey84", | ||||
|     "aliases": [ "Gray84" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 189, | ||||
| @@ -3477,7 +3486,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 100 | ||||
|     }, | ||||
|     "name": "Grey100" | ||||
|     "name": "Grey100", | ||||
|     "aliases": [ "Gray100" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 232, | ||||
| @@ -3492,7 +3502,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 3 | ||||
|     }, | ||||
|     "name": "Grey3" | ||||
|     "name": "Grey3", | ||||
|     "aliases": [ "Gray3" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 233, | ||||
| @@ -3507,7 +3518,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 7 | ||||
|     }, | ||||
|     "name": "Grey7" | ||||
|     "name": "Grey7", | ||||
|     "aliases": [ "Gray7" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 234, | ||||
| @@ -3522,7 +3534,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 10 | ||||
|     }, | ||||
|     "name": "Grey11" | ||||
|     "name": "Grey11", | ||||
|     "aliases": [ "Gray11" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 235, | ||||
| @@ -3537,7 +3550,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 14 | ||||
|     }, | ||||
|     "name": "Grey15" | ||||
|     "name": "Grey15", | ||||
|     "aliases": [ "Gray15" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 236, | ||||
| @@ -3552,7 +3566,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 18 | ||||
|     }, | ||||
|     "name": "Grey19" | ||||
|     "name": "Grey19", | ||||
|     "aliases": [ "Gray19" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 237, | ||||
| @@ -3567,7 +3582,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 22 | ||||
|     }, | ||||
|     "name": "Grey23" | ||||
|     "name": "Grey23", | ||||
|     "aliases": [ "Gray23" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 238, | ||||
| @@ -3582,7 +3598,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 26 | ||||
|     }, | ||||
|     "name": "Grey27" | ||||
|     "name": "Grey27", | ||||
|     "aliases": [ "Gray27" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 239, | ||||
| @@ -3597,7 +3614,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 30 | ||||
|     }, | ||||
|     "name": "Grey30" | ||||
|     "name": "Grey30", | ||||
|     "aliases": [ "Gray30" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 240, | ||||
| @@ -3612,7 +3630,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 34 | ||||
|     }, | ||||
|     "name": "Grey35" | ||||
|     "name": "Grey35", | ||||
|     "aliases": [ "Gray35" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 241, | ||||
| @@ -3627,7 +3646,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 37 | ||||
|     }, | ||||
|     "name": "Grey39" | ||||
|     "name": "Grey39", | ||||
|     "aliases": [ "Gray39" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 242, | ||||
| @@ -3642,7 +3662,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 40 | ||||
|     }, | ||||
|     "name": "Grey42" | ||||
|     "name": "Grey42", | ||||
|     "aliases": [ "Gray42" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 243, | ||||
| @@ -3657,7 +3678,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 46 | ||||
|     }, | ||||
|     "name": "Grey46" | ||||
|     "name": "Grey46", | ||||
|     "aliases": [ "Gray46" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 244, | ||||
| @@ -3672,7 +3694,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 50 | ||||
|     }, | ||||
|     "name": "Grey50" | ||||
|     "name": "Grey50", | ||||
|     "aliases": [ "Gray50" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 245, | ||||
| @@ -3687,7 +3710,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 54 | ||||
|     }, | ||||
|     "name": "Grey54" | ||||
|     "name": "Grey54", | ||||
|     "aliases": [ "Gray54" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 246, | ||||
| @@ -3702,7 +3726,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 58 | ||||
|     }, | ||||
|     "name": "Grey58" | ||||
|     "name": "Grey58", | ||||
|     "aliases": [ "Gray58" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 247, | ||||
| @@ -3717,7 +3742,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 61 | ||||
|     }, | ||||
|     "name": "Grey62" | ||||
|     "name": "Grey62", | ||||
|     "aliases": [ "Gray62" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 248, | ||||
| @@ -3732,7 +3758,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 65 | ||||
|     }, | ||||
|     "name": "Grey66" | ||||
|     "name": "Grey66", | ||||
|     "aliases": [ "Gray66" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 249, | ||||
| @@ -3747,7 +3774,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 69 | ||||
|     }, | ||||
|     "name": "Grey70" | ||||
|     "name": "Grey70", | ||||
|     "aliases": [ "Gray70" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 250, | ||||
| @@ -3762,7 +3790,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 73 | ||||
|     }, | ||||
|     "name": "Grey74" | ||||
|     "name": "Grey74", | ||||
|     "aliases": [ "Gray74" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 251, | ||||
| @@ -3777,7 +3806,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 77 | ||||
|     }, | ||||
|     "name": "Grey78" | ||||
|     "name": "Grey78", | ||||
|     "aliases": [ "Gray78" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 252, | ||||
| @@ -3792,7 +3822,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 81 | ||||
|     }, | ||||
|     "name": "Grey82" | ||||
|     "name": "Grey82", | ||||
|     "aliases": [ "Gray82" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 253, | ||||
| @@ -3807,7 +3838,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 85 | ||||
|     }, | ||||
|     "name": "Grey85" | ||||
|     "name": "Grey85", | ||||
|     "aliases": [ "Gray85" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 254, | ||||
| @@ -3822,7 +3854,8 @@ | ||||
|       "s": 0, | ||||
|       "l": 89 | ||||
|     }, | ||||
|     "name": "Grey89" | ||||
|     "name": "Grey89", | ||||
|     "aliases": [ "Gray89" ] | ||||
|   }, | ||||
|   { | ||||
|     "number": 255, | ||||
| @@ -3837,6 +3870,7 @@ | ||||
|       "s": 0, | ||||
|       "l": 93 | ||||
|     }, | ||||
|     "name": "Grey93" | ||||
|     "name": "Grey93", | ||||
|     "aliases": [ "Gray93" ] | ||||
|   } | ||||
| ] | ||||
| @@ -10,6 +10,7 @@ namespace Generator.Models | ||||
|         public int Number { get; set; } | ||||
|         public string Hex { get; set; } | ||||
|         public string Name { get; set; } | ||||
|         public List<string> Aliases { get; set; } = new List<string>(); | ||||
|         public Rgb Rgb { get; set; } | ||||
|  | ||||
|         public int R => Rgb.R; | ||||
| @@ -21,7 +22,23 @@ namespace Generator.Models | ||||
|             var source = JsonConvert.DeserializeObject<List<Color>>(json); | ||||
|  | ||||
|             var check = new Dictionary<string, Color>(StringComparer.OrdinalIgnoreCase); | ||||
|             foreach (var color in source.OrderBy(c => c.Number)) | ||||
|  | ||||
|             var colorAliases = source | ||||
|                 .SelectMany(c => c.Aliases.Select(a => new { Alias = a, Color = c })) | ||||
|                 .Select(a => new Color() | ||||
|                 { | ||||
|                     Hex = a.Color.Hex, | ||||
|                     Name = a.Alias, | ||||
|                     Number = a.Color.Number, | ||||
|                     Rgb = a.Color.Rgb | ||||
|                 }) | ||||
|                 .ToList(); | ||||
|  | ||||
|             var colors = source | ||||
|                 .Union(colorAliases) | ||||
|                 .OrderBy(c => c.Number); | ||||
|  | ||||
|             foreach (var color in colors) | ||||
|             { | ||||
|                 if (!check.ContainsKey(color.Name)) | ||||
|                 { | ||||
| @@ -49,7 +66,7 @@ namespace Generator.Models | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return source; | ||||
|             return colors; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -27,14 +27,18 @@ namespace Spectre.Console | ||||
|                 { "teal", 6 }, | ||||
|                 { "silver", 7 }, | ||||
|                 { "grey", 8 }, | ||||
|                 { "gray", 8 }, | ||||
|                 { "red", 9 }, | ||||
|                 { "lime", 10 }, | ||||
|                 { "yellow", 11 }, | ||||
|                 { "blue", 12 }, | ||||
|                 { "fuchsia", 13 }, | ||||
|                 { "magenta", 13 }, | ||||
|                 { "aqua", 14 }, | ||||
|                 { "cyan", 14 }, | ||||
|                 { "white", 15 }, | ||||
|                 { "grey0", 16 }, | ||||
|                 { "gray0", 16 }, | ||||
|                 { "navyblue", 17 }, | ||||
|                 { "darkblue", 18 }, | ||||
|                 { "blue3", 19 }, | ||||
| @@ -78,6 +82,7 @@ namespace Spectre.Console | ||||
|                 { "blueviolet", 57 }, | ||||
|                 { "orange4", 58 }, | ||||
|                 { "grey37", 59 }, | ||||
|                 { "gray37", 59 }, | ||||
|                 { "mediumpurple4", 60 }, | ||||
|                 { "slateblue3", 61 }, | ||||
|                 { "slateblue3_1", 62 }, | ||||
| @@ -121,6 +126,7 @@ namespace Spectre.Console | ||||
|                 { "yellow4", 100 }, | ||||
|                 { "wheat4", 101 }, | ||||
|                 { "grey53", 102 }, | ||||
|                 { "gray53", 102 }, | ||||
|                 { "lightslategrey", 103 }, | ||||
|                 { "mediumpurple", 104 }, | ||||
|                 { "lightslateblue", 105 }, | ||||
| @@ -158,12 +164,14 @@ namespace Spectre.Console | ||||
|                 { "lightsalmon3", 137 }, | ||||
|                 { "rosybrown", 138 }, | ||||
|                 { "grey63", 139 }, | ||||
|                 { "gray63", 139 }, | ||||
|                 { "mediumpurple2_1", 140 }, | ||||
|                 { "mediumpurple1", 141 }, | ||||
|                 { "gold3", 142 }, | ||||
|                 { "darkkhaki", 143 }, | ||||
|                 { "navajowhite3", 144 }, | ||||
|                 { "grey69", 145 }, | ||||
|                 { "gray69", 145 }, | ||||
|                 { "lightsteelblue3", 146 }, | ||||
|                 { "lightsteelblue", 147 }, | ||||
|                 { "yellow3", 148 }, | ||||
| @@ -207,6 +215,7 @@ namespace Spectre.Console | ||||
|                 { "lightgoldenrod2", 186 }, | ||||
|                 { "lightyellow3", 187 }, | ||||
|                 { "grey84", 188 }, | ||||
|                 { "gray84", 188 }, | ||||
|                 { "lightsteelblue1", 189 }, | ||||
|                 { "yellow2", 190 }, | ||||
|                 { "darkolivegreen1", 191 }, | ||||
| @@ -250,30 +259,55 @@ namespace Spectre.Console | ||||
|                 { "wheat1", 229 }, | ||||
|                 { "cornsilk1", 230 }, | ||||
|                 { "grey100", 231 }, | ||||
|                 { "gray100", 231 }, | ||||
|                 { "grey3", 232 }, | ||||
|                 { "gray3", 232 }, | ||||
|                 { "grey7", 233 }, | ||||
|                 { "gray7", 233 }, | ||||
|                 { "grey11", 234 }, | ||||
|                 { "gray11", 234 }, | ||||
|                 { "grey15", 235 }, | ||||
|                 { "gray15", 235 }, | ||||
|                 { "grey19", 236 }, | ||||
|                 { "gray19", 236 }, | ||||
|                 { "grey23", 237 }, | ||||
|                 { "gray23", 237 }, | ||||
|                 { "grey27", 238 }, | ||||
|                 { "gray27", 238 }, | ||||
|                 { "grey30", 239 }, | ||||
|                 { "gray30", 239 }, | ||||
|                 { "grey35", 240 }, | ||||
|                 { "gray35", 240 }, | ||||
|                 { "grey39", 241 }, | ||||
|                 { "gray39", 241 }, | ||||
|                 { "grey42", 242 }, | ||||
|                 { "gray42", 242 }, | ||||
|                 { "grey46", 243 }, | ||||
|                 { "gray46", 243 }, | ||||
|                 { "grey50", 244 }, | ||||
|                 { "gray50", 244 }, | ||||
|                 { "grey54", 245 }, | ||||
|                 { "gray54", 245 }, | ||||
|                 { "grey58", 246 }, | ||||
|                 { "gray58", 246 }, | ||||
|                 { "grey62", 247 }, | ||||
|                 { "gray62", 247 }, | ||||
|                 { "grey66", 248 }, | ||||
|                 { "gray66", 248 }, | ||||
|                 { "grey70", 249 }, | ||||
|                 { "gray70", 249 }, | ||||
|                 { "grey74", 250 }, | ||||
|                 { "gray74", 250 }, | ||||
|                 { "grey78", 251 }, | ||||
|                 { "gray78", 251 }, | ||||
|                 { "grey82", 252 }, | ||||
|                 { "gray82", 252 }, | ||||
|                 { "grey85", 253 }, | ||||
|                 { "gray85", 253 }, | ||||
|                 { "grey89", 254 }, | ||||
|                 { "gray89", 254 }, | ||||
|                 { "grey93", 255 }, | ||||
|                 { "gray93", 255 }, | ||||
|             }; | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -14,6 +14,11 @@ namespace Spectre.Console | ||||
|             _nameLookup = new Dictionary<int, string>(); | ||||
|             foreach (var pair in _numberLookup) | ||||
|             { | ||||
|                 if (_nameLookup.ContainsKey(pair.Value)) | ||||
|                 { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 _nameLookup.Add(pair.Value, pair.Key); | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Ion Dormenco
					Ion Dormenco