来自:http://www.cnblogs.com/xiaofengfeng/archive/2010/10/06/1844601.html
这篇文章来来源于C# Color Table,这里是我翻译的中文版本,其中已经加上了我的一些理解和注释。翻译这篇文章的原因是我在写C#程序的时候发现,C#自带的颜色种类极多(详见下表),如果没有直观的对照关系的话,很难从那么多的名
这篇文章来来源于C# Color Table,这里是我翻译的中文版本,其中已经加上了我的一些理解和注释。翻译这篇文章的原因是我在写C#程序的时候发现,C#自带的颜色种类极多(详见下表),如果没有直观的对照关系的话,很难从那么多的名字中挑选出中意的颜色。
以下的颜色代码取自HTML规范,这些颜色的名称对应于KnownColor的属性。比如,你可以用以下代码来创建一个Color对象:
Color c = Color.FromKnownColor(KnownColor.colorname);
所有的colorname在后面的表格中一一列出,这些颜色对应的RGB值列在名字的后面,你可以使用FromArgb方法来创建Color对象。以下两行实际上创建了同一种颜色:
Color c1 = Color.FromArgb(32,178,170);
Color c2 = Color.FromKnownColor(KnownColor.LightSeaGreen);
在下面这张表中,我严格依照颜色的RGB值设置对应颜色的显示。你所看到的真实效果依赖于浏览器是否准确处理了对应24位色的颜色显示(一些浏览器可能将某些颜色映射成“最接近的网页调色板颜色”),显示器的调节或者你显卡的校正值。因此显示效果会略有不同。
补充:
还有一些获取颜色的方式:
Color c1 = Color.AliceBlue; //Color类自带的静态颜色对象Color c2 = Color.FromArgb(0x20B2AA); //网页里面提取的颜色(原格式为#20B2AA)
C#颜色和名称对照表
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
Color.AliceBlue | 240,248,255 | Color.LightSalmon | 255,160,122 |
Color.AntiqueWhite | 250,235,215 | Color.LightSeaGreen | 32,178,170 |
Color.Aqua | 0,255,255 | Color.LightSkyBlue | 135,206,250 |
Color.Aquamarine | 127,255,212 | Color.LightSlateGray | 119,136,153 |
Color.Azure | 240,255,255 | Color.LightSteelBlue | 176,196,222 |
Color.Beige | 245,245,220 | Color.LightYellow | 255,255,224 |
Color.Bisque | 255,228,196 | Color.Lime | 0,255,0 |
Color.Black | 0,0,0 | Color.LimeGreen | 50,205,50 |
Color.BlanchedAlmond | 255,255,205 | Color.Linen | 250,240,230 |
Color.Blue | 0,0,255 | Color.Magenta | 255,0,255 |
Color.BlueViolet | 138,43,226 | Color.Maroon | 128,0,0 |
Color.Brown | 165,42,42 | Color.MediumAquamarine | 102,205,170 |
Color.BurlyWood | 222,184,135 | Color.MediumBlue | 0,0,205 |
Color.CadetBlue | 95,158,160 | Color.MediumOrchid | 186,85,211 |
Color.Chartreuse | 127,255,0 | Color.MediumPurple | 147,112,219 |
Color.Chocolate | 210,105,30 | Color.MediumSeaGreen | 60,179,113 |
Color.Coral | 255,127,80 | Color.MediumSlateBlue | 123,104,238 |
Color.CornflowerBlue | 100,149,237 | Color.MediumSpringGreen | 0,250,154 |
Color.Cornsilk | 255,248,220 | Color.MediumTurquoise | 72,209,204 |
Color.Crimson | 220,20,60 | Color.MediumVioletRed | 199,21,112 |
Color.Cyan | 0,255,255 | Color.MidnightBlue | 25,25,112 |
Color.DarkBlue | 0,0,139 | Color.MintCream | 245,255,250 |
Color.DarkCyan | 0,139,139 | Color.MistyRose | 255,228,225 |
Color.DarkGoldenrod | 184,134,11 | Color.Moccasin | 255,228,181 |
Color.DarkGray | 169,169,169 | Color.NavajoWhite | 255,222,173 |
Color.DarkGreen | 0,100,0 | Color.Navy | 0,0,128 |
Color.DarkKhaki | 189,183,107 | Color.OldLace | 253,245,230 |
Color.DarkMagena | 139,0,139 | Color.Olive | 128,128,0 |
Color.DarkOliveGreen | 85,107,47 | Color.OliveDrab | 107,142,45 |
Color.DarkOrange | 255,140,0 | Color.Orange | 255,165,0 |
Color.DarkOrchid | 153,50,204 | Color.OrangeRed | 255,69,0 |
Color.DarkRed | 139,0,0 | Color.Orchid | 218,112,214 |
Color.DarkSalmon | 233,150,122 | Color.PaleGoldenrod | 238,232,170 |
Color.DarkSeaGreen | 143,188,143 | Color.PaleGreen | 152,251,152 |
Color.DarkSlateBlue | 72,61,139 | Color.PaleTurquoise | 175,238,238 |
Color.DarkSlateGray | 40,79,79 | Color.PaleVioletRed | 219,112,147 |
Color.DarkTurquoise | 0,206,209 | Color.PapayaWhip | 255,239,213 |
Color.DarkViolet | 148,0,211 | Color.PeachPuff | 255,218,155 |
Color.DeepPink | 255,20,147 | Color.Peru | 205,133,63 |
Color.DeepSkyBlue | 0,191,255 | Color.Pink | 255,192,203 |
Color.DimGray | 105,105,105 | Color.Plum | 221,160,221 |
Color.DodgerBlue | 30,144,255 | Color.PowderBlue | 176,224,230 |
Color.Firebrick | 178,34,34 | Color.Purple | 128,0,128 |
Color.FloralWhite | 255,250,240 | Color.Red | 255,0,0 |
Color.ForestGreen | 34,139,34 | Color.RosyBrown | 188,143,143 |
Color.Fuschia | 255,0,255 | Color.RoyalBlue | 65,105,225 |
Color.Gainsboro | 220,220,220 | Color.SaddleBrown | 139,69,19 |
Color.GhostWhite | 248,248,255 | Color.Salmon | 250,128,114 |
Color.Gold | 255,215,0 | Color.SandyBrown | 244,164,96 |
Color.Goldenrod | 218,165,32 | Color.SeaGreen | 46,139,87 |
Color.Gray | 128,128,128 | Color.Seashell | 255,245,238 |
Color.Green | 0,128,0 | Color.Sienna | 160,82,45 |
Color.GreenYellow | 173,255,47 | Color.Silver | 192,192,192 |
Color.Honeydew | 240,255,240 | Color.SkyBlue | 135,206,235 |
Color.HotPink | 255,105,180 | Color.SlateBlue | 106,90,205 |
Color.IndianRed | 205,92,92 | Color.SlateGray | 112,128,144 |
Color.Indigo | 75,0,130 | Color.Snow | 255,250,250 |
Color.Ivory | 255,240,240 | Color.SpringGreen | 0,255,127 |
Color.Khaki | 240,230,140 | Color.SteelBlue | 70,130,180 |
Color.Lavender | 230,230,250 | Color.Tan | 210,180,140 |
Color.LavenderBlush | 255,240,245 | Color.Teal | 0,128,128 |
Color.LawnGreen | 124,252,0 | Color.Thistle | 216,191,216 |
Color.LemonChiffon | 255,250,205 | Color.Tomato | 253,99,71 |
Color.LightBlue | 173,216,230 | Color.Turquoise | 64,224,208 |
Color.LightCoral | 240,128,128 | Color.Violet | 238,130,238 |
Color.LightCyan | 224,255,255 | Color.Wheat | 245,222,179 |
Color.LightGoldenrodYellow | 250,250,210 | Color.White | 255,255,255 |
Color.LightGreen | 144,238,144 | Color.WhiteSmoke | 245,245,245 |
Color.LightGray | 211,211,211 | Color.Yellow | 255,255,0 |
Color.LightPink | 255,182,193 | Color.YellowGreen | 154,205,50 |
附C#颜色代码生成工具方便大家本地查看:
本篇文章来源于:开发学院 http://edu.codepub.com 原文链接:http://edu.codepub.com/2009/0601/5153.php