if use_color_brightness:
        contrast_color = _black_or_white_by_color_brightness(color)
    else:
        contrast_color = _black_or_white_by_contrast_ratio(color)
    if contrast_color == "white":
        return 1, 1, 1, 1
    else:
        return 0, 0, 0, 1


if __name__ == "__main__":
    from kivy.utils import get_color_from_hex

    from kivymd.color_definitions import colors, text_colors

    for c in colors.items():
        if c[0] in ["Light", "Dark"]:
            continue
        color = c[0]
        print(f"For the {color} color palette:")
        for name, hex_color in c[1].items():
            if hex_color:
                col = get_color_from_hex(hex_color)
                col_bri = get_contrast_text_color(col)
                con_rat = get_contrast_text_color(col,
                                                  use_color_brightness=False)
                text_color = text_colors[c[0]][name]
                print(f"   The {name} hue gives {col_bri} using color "
                      f"brightness, {con_rat} using contrast ratio, and "
                      f"{text_color} from the MD spec")

def get_contrast_text_color(color, use_color_brightness=True):
    if use_color_brightness:
        contrast_color = _black_or_white_by_color_brightness(color)
    else:
        contrast_color = _black_or_white_by_contrast_ratio(color)
    if contrast_color == 'white':
        return 1, 1, 1, 1
    else:
        return 0, 0, 0, 1


if __name__ == '__main__':
    from kivy.utils import get_color_from_hex
    from kivymd.color_definitions import colors, text_colors
    for c in list(colors.items()):
        if c[0] in ['Light', 'Dark']:
            continue
        print(("For the {} color palette:".format(c[0])))
        for name, hex_color in list(c[1].items()):
            if hex_color:
                col = get_color_from_hex(hex_color)
                col_bri = get_contrast_text_color(col)
                con_rat = get_contrast_text_color(col,
                                                  use_color_brightness=False)
                text_color = text_colors[c[0]][name]
                print((
                    "   The {} hue gives {} using color brightness, {} using contrast ratio, and {} from the MD spec"
                    .format(name, col_bri, con_rat, text_color)))