Microsoft.Maui.Graphics
Microsoft.Maui.Graphics copied to clipboard
Colors.DarkGray returns wrong value
Description
The constant Microsoft.Maui.Graphics.Colors.DarkGray returns wrong value. Compared to other colors, DarkGray is lighter than Gray.
This probably affects all platforms.
Like other colors such as DarkBlue, DarkGreen, DarkRed, etc should "Dark" designate a color that is darker than the average.
Version: Microsoft Visual Studio 17.3.0 Preview 1.1
Steps to Reproduce
Compare the luminance of DarkGray and Gray Demo project comparing colors
Version with bug
Unknown/Other (please specify)
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows, I was not able test on other platforms
Affected platform versions
Windows 10 19044.1706
Did you find any workaround?
No response
Relevant log output
No response
For better or worse, this seems to match the W3C color names/values: https://www.w3.org/wiki/CSS/Properties/color/keywords
And apparently there's some history to this: https://caspervonb.medium.com/why-dark-gray-is-brighter-than-gray-in-css-138c59ae51c3
My view is that while this is definitely weird, it's baked into history, and changing it would be a change that could degrade the behavior of applications. It could alter the contrast/readability/accessibility of existing apps.
I recommend leaving this as-is.
Anyone who knows that DarkGray is not really dark gray, will use a substitute. No one will use the wrong DarkGray constant intentional to get a lighter gray as light gray. So IMHO it can be changed, especially because not so many productive apps have been developed with MAUI so far, the change should not have a big impact. ;-)
The earliest this could be fixed would be in the .NET 7 timeframe, meaning there would be 6 months of .NET 6 / MAUI 6 apps that will have been built. I think the cost of changing it is far greater than the benefit. The benefit is that the colors exactly match the W3C standard. Just like there are some typos preserved in RFCs (see https://en.wikipedia.org/wiki/HTTP_referer).
I think that whoever uses that color will run their app and either like the color and use it, or not like the color and not use it. I think adding a doc comment saying "warning: this isn't as dark as you think" could be a reasonable mitigation that costs very little and has no downside.
It would be stupid to make the same mistake over and over again, just because it is defined in a standard ;-) Adding a warning is only the half way.
If the wrong value is to be kept (which IMHO is not necessary, but I'm not the center of the world), then there should at least be an alternative class on a known place, because everyone who knows the error will create their own corrected class or at least search if there is one.
- rename DarkGray to
DarkGray W3C
/DarkGrayWeb
and addDarkGray
with a corrected value - rename Colors to
W3CColors
/WebColors
or simlar with the wrong DarkGray and add the newColors
with the corrected DarkGray. - To be more backward compatible maybe keep
DarkGray
as is and addDarkGrayFix
(look for a better name) with the corrected value. - To be more backward compatible maybe keep
Colors
as is and addProperColors
(look for a better name) with the corrected DarkGray.
All solutions would save most developers unnecessary work. I would prefer 1)
Options 1 and 2 are breaking changes, which has an enormous cost on users (both app developers, and the users of those apps). We simply cannot break existing apps unless it is absolutely necessary, and in this case it is clearly not necessary. The other options described here are worth considering, but I think the value they bring is quite limited. And, the reason it's important to stick to a standard, even if it's weird, is that is ensures consistency across platforms, which is what everyone is trying to do. If MAUI DarkGray is different from Windows DarkGray or HTML/CSS DarkGray, that would also be considered a bug, and arguably a worse one.
Never mind, it seems most don't care, for whatever reason. But it remains
DarkGray is not darker then gray use DarkerGray
I will print a T-shirt with it ;-)
One last wish to make the things better:
Please consider to add a new constant DarkerGray
, this will not break anything and sets a sign that one knows about this anomaly. The value 2B2B2B has the opposide luminosity of LightGrray and would be a value I would use for it.
Thanks and greetings to the team and all contributors.
Bug report: Fix spelling: darker *than* gray
.
Feature request Please make two t-shirts, one spelled gray (typical US English), and one spelled grey (typical British English)
😁😁😁
EDIT: V2 😁