Describe the problem this feature would solve
For a given color, it would be useful to know the contrasting color for displaying text (white/black). This can also be useful to determine the RequestedTheme for a control based on a given background color.
Describe the solution
A new helper method would be added to ColorHelpers class, which would calculate perceived luminance for a given color using the following formula (based on W3C):
( 0.299 * color.R + 0.587 * color.G + 0.114 * color.B)/255
The result would be a number between 0 and 1, for 0.5 being the boundary between black/white foreground color.
Describe alternatives you've considered
The method could also be added as an extension method on the Windows.UI.Color type.
Describe the problem this feature would solve
For a given color, it would be useful to know the contrasting color for displaying text (white/black). This can also be useful to determine the
RequestedThemefor a control based on a given background color.Describe the solution
A new helper method would be added to
ColorHelpersclass, which would calculate perceived luminance for a given color using the following formula (based on W3C):The result would be a number between 0 and 1, for 0.5 being the boundary between black/white foreground color.
Describe alternatives you've considered
The method could also be added as an extension method on the
Windows.UI.Colortype.