.net 为什么深灰色比灰色轻?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3811973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:46:23  来源:igfitidea点击:

Why is DarkGray lighter than Gray?

.netsystem.drawing

提问by Benjol

Simple curiosity here, tinged with some practical concerns because I get caught out by this occasionally.

简单的好奇心,带有一些实际问题,因为我偶尔会被这个问题所吸引。

How come Color.DarkGrayis lighter than Color.Gray?

怎么Color.DarkGray比轻Color.Gray

回答by Peter

Wikipedia has some information on the subject. It sounds like a lot of the named color definitions come from X Windows System. On X, "Gray" is actually closer to "Silver". However, the W3C defined Gray (more appropriately?) as RGB 50%.

维基百科有一些关于这个主题的信息。听起来很多命名的颜色定义来自 X Windows 系统。在 X 上,“灰色”实际上更接近于“银色”。然而,W3C 将灰色(更恰当地?)定义为 RGB 50%。

Here's some more Wikipediaon the subject:

这是有关该主题的更多维基百科

Perhaps most unusual of the color clashes between X11 and W3C is the case of "Gray" and its variants. In HTML, "Gray" is specifically reserved for the 128 triplet (50% gray). However, in X11, "gray" was assigned to the 190 triplet (74.5%), which is close to W3C "Silver" at 192 (75.3%), and had "Light Gray" at 211 (83%) and "Dark Gray" at 169 (66%) counterparts. As a result, the combined CSS 3.0 color list that prevails on the web today produces "Dark Gray" as a significantly lighter tone than plain "Gray", because "Dark Gray" was descended from X11 – for it did not exist in HTML nor CSS level 1 – while "Gray" was descended from HTML. Even in the current draft for CSS 4.0, dark gray continues to be a lighter shade than gray.

也许 X11 和 W3C 之间最不寻常的颜色冲突是“灰色”及其变体的情况。在 HTML 中,“灰色”专门用于 128 三元组(50% 灰色)。但是,在X11中,“灰色”被分配给了190个三元组(74.5%),接近W3C“银色”的192(75.3%),在211(83%)和“深灰色”处有“浅灰色” " 在 169 (66%) 个同行。结果,今天在网络上流行的组合 CSS 3.0 颜色列表产生了“深灰色”作为比普通“灰色”明显更浅的色调,因为“深灰色”是 X11 的后代——因为它不存在于 HTML 中,也不存在于CSS 级别 1 – 而“灰色”是从 HTML 继承而来的。即使在当前的 CSS 4.0 草案中,深灰色仍然比灰色更浅。

W3C colorkeywords:

W3C颜色关键词:

DimGray    '#696969'  (105,105,105)  
Gray       '#808080'  (128,128,128)
DarkGray   '#A9A9A9'  (169,169,169)  //equal to X11 DarkGray
Silver     '#C0C0C0'  (192,192,192)  //close to X11 Gray (190,190,190)
LightGray  '#D3D3D3'  (211,211,211)  //equal to X11 LightGray
Gainsboro  '#DCDCDC'  (220,220,220)

回答by Glenn Slayden

W3C Grays
Nine assigned names where the R, G, and B values are numerically equal:

W3C Grays
九个指定的名称,其中 R、G 和 B 值在数字上相等:

enter image description here

在此处输入图片说明

回答by Cary Bondoc

I would like to quote Tim Sneath's discussionregarding that,

我想引用Tim Sneath对此的讨论

These colours don't actually originate in HTML`- they date still further back than that to the X Window System that originated on UNIX systems.The HTML specification defines sixteen named colours that map onto the basic sixteen colours present in the EGA palette, but the earliest browsers such as Mosaic also supported any of the other X11 named colours, based on their colour representation as defined on X. Unfortunately, some of the original sixteen named colours have different representations to the X11 equivalents, for example Green is represented in X11 in this colour, whereas in HTML it's represented in this colour. The unfortunate result is that Gray is defined as #808080 in HTML, but DarkGray is represented as #A9A9A9, meaning that they're the wrong way around. Since WPF allows the same named colours as HTML for compatibility, the result is that the same idiosyncrasies carry forward. (You can find more information on the full set of X11 colour names and their representations in Wikipedia).

这些颜色实际上并非起源于 HTML`- 它们的历史比起源于 UNIX 系统的 X Window System 还要早。HTML 规范定义了 16 种命名颜色,这些颜色映射到 EGA 调色板中存在的基本 16 种颜色上,但最早的浏览器(如 Mosaic)也支持任何其他 X11 命名颜色,基于它们在 X 上定义的颜色表示。不幸的是,一些最初的十六种命名颜色与 X11 等价物有不同的表示,例如绿色在 X11 中用这种颜色表示,而在 HTML 中它用这种颜色表示。不幸的结果是,灰色在 HTML 中被定义为 #808080,但 DarkGray 被表示为 #A9A9A9,这意味着它们是错误的。由于 WPF 允许使用与 HTML 相同的命名颜色以实现兼容性,因此结果是相同的特质得以延续。

That's why the author also states that it is better to use the hex or scRGBto represent colors.

这就是为什么作者还指出最好使用hex或scRGB来表示颜色的原因。

My recommendation therefore is in general to use the hex or scRGBcolour representations wherever possible, or you might be surprised by the colours that you pick not matching your expectations!

因此,我的建议通常是尽可能使用十六进制或scRGB颜色表示,否则您可能会对您选择的颜色不符合您的期望感到惊讶!