Return ANSI-escaped colored string.

@param  {string} string
@param  {string} color
@return {string}
@api public
481103
function(string, color) {
      return "\u001B[" + {
       bold    : 1,
       black   : 30,
       red     : 31,
       green   : 32,
       yellow  : 33,
       blue    : 34,
       magenta : 35,
       cyan    : 36,
       white   : 37
      }[color] + 'm' + string + "\u001B[0m"
    }
805430
function nameToHex(color: string): string {
  if (typeof color !== 'string') return color
  const normalizedColorName = color.toLowerCase()
  return namedColorMap[normalizedColorName]
    ? `#${namedColorMap[normalizedColorName]}`
    : color
}
1299941
public function color($string = null, $color = null, $background = null) {
		$result = '';
		
		if ($color !== null) {
			$result = sprintf(self::COLOR_PATTERN, $this->_fontColors[$color]);
		}
		
		if ($background !== null) {
			$result .= sprintf(self::COLOR_PATTERN, $this->_backgroundColors[$background]);
		}
		
		return $result . $string . sprintf(self::COLOR_PATTERN, 0);
	}
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;
}
702558
function colorString(value) {
  const asColor = color(value);
  const r = asColor.r.toString(16);
  const g = asColor.g.toString(16);
  const b = asColor.b.toString(16);

  return `#${r.length === 1 ? '0' : ''}${r}${g.length === 1 ? '0' : ''}${g}${b.length === 1 ? '0' : ''}${b}`;
}
703722
function coloredLog (color, string, underline) {
  let chosenColor
  switch (color) {
    case 'red':
      chosenColor = '\x1b[31m'
      break
    case 'green':
      chosenColor = '\x1b[32m'
      break
    case 'blue':
      chosenColor = '\x1b[34m'
      break
    default:
      chosenColor = '\x1b[0m'
      break
  }
  console.log(`${chosenColor}${underline ? '\x1b[4m' : ''}%s\x1b[0m`, string)
}
715237
protected String colorString(int ir, int ig, int ib)
    {
    	return String.format("#%02x%02x%02x", ir, ig, ib);
    }
205387
function useColors() {
	return 'colors' in exports.inspectOpts ?
		Boolean(exports.inspectOpts.colors) :
		tty.isatty(process.stderr.fd);
}
1045255
function curlyColors(str) {
  var res = '';
  var esc;
  var match;
  var history = [];
  var lastIndex = 0;

  if (arguments.length >= 2) str = format.apply(null, slice.apply(arguments));

  while ((match = rx.exec(str)) !== null) {
    res += str.slice(lastIndex, match.index);
    if (match[1]) {
      // Opening tag found.
      // Append the starting escape string sequence.
      esc = colors[match[1]];
      history.push(esc);
      res += esc[0];
    } else if (history.length) {
      // Closing tag found.
      // Append the closing escape string sequence of the current color.
      res += history.pop()[1];
      if (history.length) {
        // Continue with previous starting escape string sequence.
        res += history[history.length - 1][0];
      }
    }
    lastIndex = match.index + match[0].length;
  }

  // Append the remaining string to the result string.
  res += str.slice(lastIndex);

  // Close all remaining tags.
  while (history.length) res += history.pop()[1];

  // Delete double occurrences of color sequences.
  res = res.replace(/(\x1b\[\d+m)\1{1,}/g, '$1');

  return res;
}
653125
function escapeString(string) {
  var result = '';
  var char;
  var escapeSeq;

  for (var i = 0; i < string.length; i++) {
    char = string.charCodeAt(i);
    escapeSeq = ESCAPE_SEQUENCES[char];
    result += !escapeSeq && isPrintable(char)
      ? string[i]
      : escapeSeq || encodeHex(char);
  }

  return result;
}
479238
function string_to_color(str) {
	// Generate a Hash for the String
	var hash = function(word) {
		var h = 0;
		for (var i = 0; i < word.length; i++) {
			h = word.charCodeAt(i) + ((h << 5) - h);
		}
		return h;
	};

	// Change the darkness or lightness
	var shade = function(color, prc) {
		var num = parseInt(color, 16),
		    amt = Math.round(2.55 * prc),
		    R = (num >> 16) + amt,
		    G = (num >> 8 & 0x00FF) + amt,
		    B = (num & 0x0000FF) + amt;
		return (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
			(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
			(B < 255 ? B < 1 ? 0 : B : 255))
			.toString(16)
			.slice(1);
	};

	// Convert init to an RGBA
	var int_to_rgba = function(i) {
		var color = ((i >> 24) & 0xFF).toString(16) +
			((i >> 16) & 0xFF).toString(16) +
			((i >> 8) & 0xFF).toString(16) +
			(i & 0xFF).toString(16);
		return color;
	};

	return shade(
		int_to_rgba(hash(str)),
		-10
	);
}
579510
public function colour($string, $colour)
    {
        try {
            return $this->color->__invoke($string)
                ->apply($colour)
                ->__toString();
        } catch (NoStyleFoundException $e) {
            return $string;
        }
    }
716432
function parseColor (str) {
    if (str.substr(0,1) === '#') {
      // Handle color shorthands (like #abc)
      var shorthand = str.length === 4,
          m = str.match(shorthand ? /\w/g : /\w{2}/g);

      if (!m) return;
      m = m.map(function(s) { return parseInt(shorthand ? s+s : s, 16) });
      return new nodes.RGBA(m[0],m[1],m[2],1);
    }
    else if (str.substr(0,3) === 'rgb'){
      var m = str.match(/([0-9]*\.?[0-9]+)/g);
      if (!m) return;
      m = m.map(function(s){return parseFloat(s, 10)});
      return new nodes.RGBA(m[0], m[1], m[2], m[3] || 1);
    }
    else {
      var rgb = colors[str];
      if (!rgb) return;
      return new nodes.RGBA(rgb[0], rgb[1], rgb[2], 1);
    }
  }
331496
function(color) {
            var normalizedColor = Splunk.util.normalizeColor(color);

            return (normalizedColor) ? parseInt(normalizedColor.replace("#", "0x"), 16) : 0;
        }
406798
function gli_color_to_css(color) {
    var res = (color & 0xFFFFFF).toString(16);
    while (res.length < 6) {
        res = '0' + res;
    }
    return '#' + res.toUpperCase();
}
874477
function ( color ) {
            return color.replace( this.REG_RGB, function ( str, r, g, b, a ) {
                //RGBA문자열도 Hex문자열로 반환, "AARRGGBB"
                /*
                 var a = (a)? Math.abs(255 * a - 255) : 0,
                 uint = a << 24 | r << 16 | g << 8 | b;
                 */
                var uint = r << 16 | g << 8 | b;
                return '#' + $B.string.format( uint.toString(16), 6 );
            });
        }
891196
function ( color ) {
            var hsla = {};
            color.replace( this.REG_HSL, function ( str, h, s, l, a ) {
                hsla = {h: parseFloat(h), s: parseFloat(s), l: parseFloat(l), a: 1};
                if ( a ) hsla.a = Number(a);
            });
            return hsla;
        }