def convert_base16_to_template_data(base16_theme):
    base16_data = {}
    for key, value in base16_theme.items():
        if not key.startswith('base'):
            base16_data[key] = value
            try:
                # @TODO: check theme model for color types only:
                color_list_from_hex(value)
                int_list_from_hex(value)
            except Exception:
                continue

        hex_key = key + '-hex'
        base16_data[hex_key] = value
        base16_data[hex_key + '-r'], \
            base16_data[hex_key + '-g'], \
            base16_data[hex_key + '-b'] = \
            color_list_from_hex(value)

        rgb_key = key + '-rgb'
        base16_data[rgb_key + '-r'], \
            base16_data[rgb_key + '-g'], \
            base16_data[rgb_key + '-b'] = \
            int_list_from_hex(value)

        dec_key = key + '-dec'
        base16_data[dec_key + '-r'], \
            base16_data[dec_key + '-g'], \
            base16_data[dec_key + '-b'] = \
            [
                channel/255 for channel in int_list_from_hex(value)
            ]
    return base16_data
Ejemplo n.º 2
0
def convert_base16_to_template_data(base16_theme):
    base16_data = {}
    for key, value in base16_theme.items():
        if not key.startswith('base'):
            base16_data[key] = value
            continue

        hex_key = key + '-hex'
        base16_data[hex_key] = value
        base16_data[hex_key + '-r'], \
            base16_data[hex_key + '-g'], \
            base16_data[hex_key + '-b'] = \
            color_list_from_hex(value)

        rgb_key = key + '-rgb'
        base16_data[rgb_key + '-r'], \
            base16_data[rgb_key + '-g'], \
            base16_data[rgb_key + '-b'] = \
            int_list_from_hex(value)

        dec_key = key + '-dec'
        base16_data[dec_key + '-r'], \
            base16_data[dec_key + '-g'], \
            base16_data[dec_key + '-b'] = \
            [
                channel/255 for channel in int_list_from_hex(value)
            ]
    return base16_data
Ejemplo n.º 3
0
def convert_base16_to_template_data(base16_theme):
    base16_data = {}
    for key, value in base16_theme.items():
        if not key.startswith('base'):
            base16_data[key] = value
            continue

        hex_key = key + '-hex'
        base16_data[hex_key] = value
        base16_data[hex_key + '-r'], \
            base16_data[hex_key + '-g'], \
            base16_data[hex_key + '-b'] = \
            color_list_from_hex(value)

        rgb_key = key + '-rgb'
        base16_data[rgb_key + '-r'], \
            base16_data[rgb_key + '-g'], \
            base16_data[rgb_key + '-b'] = \
            int_list_from_hex(value)

        dec_key = key + '-dec'
        base16_data[dec_key + '-r'], \
            base16_data[dec_key + '-g'], \
            base16_data[dec_key + '-b'] = \
            [
                channel/255 for channel in int_list_from_hex(value)
            ]
    return base16_data
Ejemplo n.º 4
0
def get_gray_colors(palette):
    list_of_colors = [[hex_to_int(s) for s in color_list_from_hex(c)]
                      for c in palette]
    saturation_list = sorted(list_of_colors, key=sort_by_saturation)
    gray_colors = saturation_list[:(len(saturation_list) // 3)]
    gray_colors.sort(key=sum)
    gray_colors = [color_hex_from_list(c) for c in gray_colors]
    return gray_colors
Ejemplo n.º 5
0
def get_gray_colors(palette):
    list_of_colors = [[hex_to_int(s) for s in color_list_from_hex(c)] for c in palette]
    saturation_list = sorted(
        list_of_colors,
        key=sort_by_saturation
    )
    gray_colors = saturation_list[:(len(saturation_list)//3)]
    gray_colors.sort(key=sum)
    gray_colors = [color_hex_from_list(c) for c in gray_colors]
    return gray_colors
Ejemplo n.º 6
0
def hex_darker(color_text, darken_amount=10):
    return color_hex_from_list([
        max(min(hex_to_int(channel_text) - darken_amount, 255), 0)
        for channel_text in color_list_from_hex(color_text)
    ])