Convert a named color definition to Windows console color foreground,
    background and style numbers.
438010
def get_win_color(color):
    """"""
    foreground = background = style = None
    control = ''
    if ";" in color:
        control, color = color.split(";", 1)
        if control == bold:
            style = colorama.BRIGHT
    if color in InverseColors:
        background = WinColor[color]
    else:
        foreground = WinColor.get(color)
    return foreground, background, style
498511
def foreground_color_attribute(styles={})
      return nil if styles.nil?
      value = styles[:foreground_color]
      value ||= styles[:color]
      return nil unless value && value.is_a?(UIColor)
      value
    end
287935
function generateColors(conf) {
  for (var key in conf.color) {
    if (typeof conf.color[key] !== 'string') continue;
    conf.color[key] = new Color(conf.color[key]);
  }
  return conf;
}
894403
def get_color_scheme(name):
    """"""
    name = name.lower()
    scheme = {}
    for key in COLOR_SCHEME_KEYS:
        try:
            scheme[key] = CONF.get('appearance', name+'/'+key)
        except:
            scheme[key] = CONF.get('appearance', 'spyder/'+key)
    return scheme
919441
function applyCustomColors(config) {
  const { colors } = getAppSettings();

  if (!config.hasOwnProperty('colors')) {
    return {
      ...config,
      colors,
    };
  }

  return {
    ...config,
    colors: {
      ...config.colors,
      ...colors,
    },
  };
}
394459
function Colorizer() {
    "use strict";
    /*eslint no-multi-spaces:0*/
    var options    = { bold: 1, underscore: 4, blink: 5, reverse: 7, conceal: 8 };
    var foreground = { black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37 };
    var background = { black: 40, red: 41, green: 42, yellow: 43, blue: 44, magenta: 45, cyan: 46, white: 47 };
    var styles     = {
        'ERROR':     { bg: 'red', fg: 'white', bold: true },
        'INFO':      { fg: 'green', bold: true },
        'TRACE':     { fg: 'green', bold: true },
        'PARAMETER': { fg: 'cyan' },
        'COMMENT':   { fg: 'yellow' },
        'WARNING':   { fg: 'red', bold: true },
        'GREEN_BAR': { fg: 'white', bg: 'green', bold: true },
        'RED_BAR':   { fg: 'white', bg: 'red', bold: true },
        'INFO_BAR':  { bg: 'cyan', fg: 'white', bold: true },
        'WARN_BAR':  { bg: 'yellow', fg: 'white', bold: true },
        'SKIP':      { fg: 'magenta', bold: true },
        'SKIP_BAR':  { bg: 'magenta', fg: 'white', bold: true }
    };

    /**
     * Adds a style to provided text.
     *
     * @param   String  text
     * @param   String  styleName
     * @return  String
     */
    this.colorize = function colorize(text, styleName, pad) {
        if ((fs.isWindows() && (!env['ANSICON'] && env['ConEmuANSI'] !== 'ON')) || !(styleName in styles)) {
            return text;
        }
        return this.format(text, styles[styleName], pad);
    };

    /**
     * Formats a text using a style declaration object.
     *
     * @param  String  text
     * @param  Object  style
     * @return String
     */
    this.format = function format(text, style, pad) {
        if ((fs.isWindows() && (!env['ANSICON'] && env['ConEmuANSI'] !== 'ON')) || !utils.isObject(style)) {
            return text;
        }
        var codes = [];
        if (style.fg && foreground[style.fg]) {
            codes.push(foreground[style.fg]);
        }
        if (style.bg && background[style.bg]) {
            codes.push(background[style.bg]);
        }
        for (var option in options) {
            if (option in style && style[option] === true) {
                codes.push(options[option]);
            }
        }
        // pad
        if (typeof pad === "number" && text.length < pad) {
            text += new Array(pad - text.length + 1).join(' ');
        }
        return "\u001b[" + codes.join(';') + 'm' + text + "\u001b[0m";
    };
}
704776
def set_color_scheme(self, foreground_color, background_color):
        """"""
        if dark_color(foreground_color):
            self.default_foreground_color = 30
        else:
            self.default_foreground_color = 37

        if dark_color(background_color):
            self.default_background_color = 47
        else:
            self.default_background_color = 40
397081
def terminal_sexy_to_wal(data):
    """"""
    data["colors"] = {}
    data["special"] = {
        "foreground": data["foreground"],
        "background": data["background"],
        "cursor": data["color"][9]
    }

    for i, color in enumerate(data["color"]):
        data["colors"]["color%s" % i] = color

    return data
393728
def console_set_key_color(
    con: tcod.console.Console, col: Tuple[int, int, int]
) -> None:
    
    lib.TCOD_console_set_key_color(_console(con), col)
    if hasattr(con, "set_key_color"):
        con.set_key_color(col)
785132
def set_console(stream=STDOUT, foreground=None, background=None, style=None):
    """"""
    if foreground is None:
        foreground = _default_foreground
    if background is None:
        background = _default_background
    if style is None:
        style = _default_style
    attrs = get_attrs(foreground, background, style)
    SetConsoleTextAttribute(stream, attrs)
406798
function gli_color_to_css(color) {
    var res = (color & 0xFFFFFF).toString(16);
    while (res.length < 6) {
        res = '0' + res;
    }
    return '#' + res.toUpperCase();
}
466807
def console_get_default_foreground(con: tcod.console.Console) -> Color:
    
    return Color._new_from_cdata(
        lib.TCOD_console_get_default_foreground(_console(con))
    )
73362
def color_to_hex(color):
    """"""
    if color is None or colorConverter.to_rgba(color)[3] == 0:
        return 'none'
    else:
        rgb = colorConverter.to_rgb(color)
        return '#{0:02X}{1:02X}{2:02X}'.format(*(int(255 * c) for c in rgb))
354137
def ChargeColorMapping(maptype='jet', reverse=False):
    """"""

    pos_color = '#FF0000'
    neg_color = '#0000FF'
    neut_color = '#000000'

    mapping_d = {'A':neut_color,'R':pos_color,'N':neut_color,\
                 'D':neg_color,'C':neut_color,'Q':neut_color,\
                 'E':neg_color,'G':neut_color,'H':pos_color,\
                 'I':neut_color,'L':neut_color,'K':pos_color,\
                 'M':neut_color,'F':neut_color,'P':neut_color,\
                 'S':neut_color,'T':neut_color,'W':neut_color,\
                 'Y':neut_color,'V':neut_color}

    return (None, mapping_d, None)
1344209
function getColors(rawData) {

    // Regular expression matching colors variables naming pattern
    var REGEX = /^dc-(.*?)[0-9]+$/;

    var content = rawData
        .filter((item) => {
            var group = item.group[0];
            return group === 'colors'
                && item.context.type === 'variable'
                && item.context.name.match(REGEX);
        })
        .map((item) => {
            // extract color name (eg. `dc-magenta10 -> magenta`)
            item.color = item.context.name.replace(REGEX, '$1');
            item.color = _.capitalize(item.color);
            return item;
        });

    // transform colors array in a object, shaped as the view layer expect
    content = _.groupBy(content, (c) => c.color );
    Object.keys(content).forEach((color) => {
        content[color] = content[color].reduce((acc, c) => {
            acc['$' + c.context.name] = c.context.value;
            return acc;
        }, {});
    });
    return content;
}
667539
def foreground(color, content, readline=False):
    
    return encode(color, readline=readline) + content + encode(DEFAULT, readline=readline)
117839
function stringInputToObject(color) {

    color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
    var named = false;
    if (names[color]) {
        color = names[color];
        named = true;
    }
    else if (color == 'transparent') {
        return { r: 0, g: 0, b: 0, a: 0, format: "name" };
    }

    // Try to match string input using regular expressions.
    // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
    // Just return an object and let the conversion functions handle that.
    // This way the result will be the same whether the tinycolor is initialized with string or object.
    var match;
    if ((match = matchers.rgb.exec(color))) {
        return { r: match[1], g: match[2], b: match[3] };
    }
    if ((match = matchers.rgba.exec(color))) {
        return { r: match[1], g: match[2], b: match[3], a: match[4] };
    }
    if ((match = matchers.hsl.exec(color))) {
        return { h: match[1], s: match[2], l: match[3] };
    }
    if ((match = matchers.hsla.exec(color))) {
        return { h: match[1], s: match[2], l: match[3], a: match[4] };
    }
    if ((match = matchers.hsv.exec(color))) {
        return { h: match[1], s: match[2], v: match[3] };
    }
    if ((match = matchers.hsva.exec(color))) {
        return { h: match[1], s: match[2], v: match[3], a: match[4] };
    }
    if ((match = matchers.hex8.exec(color))) {
        return {
            r: parseIntFromHex(match[1]),
            g: parseIntFromHex(match[2]),
            b: parseIntFromHex(match[3]),
            a: convertHexToDecimal(match[4]),
            format: named ? "name" : "hex8"
        };
    }
    if ((match = matchers.hex6.exec(color))) {
        return {
            r: parseIntFromHex(match[1]),
            g: parseIntFromHex(match[2]),
            b: parseIntFromHex(match[3]),
            format: named ? "name" : "hex"
        };
    }
    if ((match = matchers.hex4.exec(color))) {
        return {
            r: parseIntFromHex(match[1] + '' + match[1]),
            g: parseIntFromHex(match[2] + '' + match[2]),
            b: parseIntFromHex(match[3] + '' + match[3]),
            a: convertHexToDecimal(match[4] + '' + match[4]),
            format: named ? "name" : "hex8"
        };
    }
    if ((match = matchers.hex3.exec(color))) {
        return {
            r: parseIntFromHex(match[1] + '' + match[1]),
            g: parseIntFromHex(match[2] + '' + match[2]),
            b: parseIntFromHex(match[3] + '' + match[3]),
            format: named ? "name" : "hex"
        };
    }

    return false;
}