I don't know if this was posted here before, but I couldn't find something similar.
I needed a simple test whether to draw light or dark text on a canvas with a not predefined color. There are some algorithms and explanations out there which are more or lesse complex. Some even used several stages to determine the best contrast, some adjust by human perception and so on.
However, the simplest one I found is already suiting my needs (and also uses a simple calculation regarding perception) and maybe someone else can use this too (looking at ObjectTheme and auto creation of themes or so):
Code: Select all
Macro IsDark(Color)
Bool(0.299*Red(Color)+0.587*Green(Color)+0.114*Blue(Color)<=186)
EndMacro