Color correctedTextColor(Color textColor, Color backgroundColor) 
{
    
    int d = differenceSquared(textColor, backgroundColor);
    if (d > 65025) {
        return textColor;
    }
    
    int distanceFromWhite = differenceSquared(textColor, Color::white);
    int distanceFromBlack = differenceSquared(textColor, Color::black);

    if (distanceFromWhite < distanceFromBlack) {
        return textColor.dark();
    }
    
    return textColor.light();
}

Unknown