Description
I often need the textColor of buttons, fields or widgets to change based on background colour (eg on highlight), and need this to be black or white (or at least a defined dark and light colour, rather than a random opposing colour) to provide a consistent interface.
I may have missed it, but can't see such a function in the library, although it's simple enough.
If i understood the mostReadable function correctly it determines what the most readable colour is, but not necessarily what i want for my interface; and defaults to black or white only when the 'most readable' isn't readable.
While this is useful, i prefer a simpler, more straightforward methods such as:
// Dichotomous color (eg. black or white) defined by brightness of given color
// intended for text color for max contrast with underlying colour
function hiContrastForColor pColor, colorForLight, colorForDark
if colorForLight is empty then put "black" into colorForLight //i.e. defaults to black for light colours
if colorForDark is empty then put "white" into colorForDark //i.e. defaults to white for dark colours
if isDark(pColor) then
return colorForDark
else
return colorForLight
end if
end hiContrastForColor
would it be possible to consider this or something like this for an addition to the library?
Of if it's already present please do point this out.
Thank you