This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Selects light or dark color for foreground (mainly text) based on background color | |
* @param bgColor Background color to evaluate | |
* @param lightColor Light foreground color (defaults to white) | |
* @param darkColor Dark foreground color (defaults to black) | |
* @returns Light or dark color based on background color | |
* @see https://stackoverflow.com/a/41491220 | |
*/ | |
function pickTextColorBasedOnBgColorAdvanced(bgColor: string, lightColor = '#FFFFFF', darkColor = '#000000'): string { | |
const color = (bgColor.startsWith('#')) ? bgColor.substring(1, 7) : bgColor; |
OlderNewer