import { combineColors , highContrastColor } from './color_calcs' ; import { colorToRgba , RGBATupleToString } from './color_library_wrappers' ; import { Color , Colors } from './colors' ; internal export const TRANSPARENT_LIMIT = 0.6 ; internal export function fillTextColor ( fallbackBGColor , foreground , background = Colors . Transparent . keyword ) { let backgroundRGBA = colorToRgba ( background ) ; if ( backgroundRGBA [ 3 ] < TRANSPARENT_LIMIT ) { backgroundRGBA = colorToRgba ( fallbackBGColor ) ; } if ( foreground ) { const foregroundRGBA = colorToRgba ( foreground ) ; const blendedFgBg = combineColors ( foregroundRGBA , backgroundRGBA ) ; return RGBATupleToString ( highContrastColor ( blendedFgBg ) ) ; } return RGBATupleToString ( highContrastColor ( backgroundRGBA ) ) ; }