This function generates a 256 jet colormap of HTML-like
    hex string colors (e.g. FF88AA)
322108
def generateColorMap():
    '''
    
    '''
    Map = cm.jet(np.arange(256))
    stringColors = []
    for i in range(Map.shape[0]):
        rgb = (int(255*Map[i][0]), int(255*Map[i][1]), int(255*Map[i][2]))
        if (sys.version_info > (3, 0)):
            stringColors.append((struct.pack('BBB', *rgb).hex())) # python 3
        else:
            stringColors.append(
                struct.pack('BBB', *rgb).encode('hex'))  # python2

    return stringColors
1197012
function transformHexAlpha(string, source, decl) {

	return recurse(string);

	function recurse(input) {
		var hexa_pos = input.indexOf('hexa');
		var subs = input.substring(hexa_pos);
		
		var h = HEX_RE.exec(subs);
		var o = OPACITY_RE.exec(subs);
		
		var i_h = INV_HEX_RE.exec(subs);
		var i_o = INV_OPACITY_RE.exec(subs);
		
		if(i_h !== null){
			throw decl.error('Invalid hex color: ' + i_h[0], { plugin: 'postcss-color-hexa' });
		}
		
		if(i_o !== null){
			throw decl.error('Invalid opacity: ' + i_o[0], { plugin: 'postcss-color-hexa' });
		}

		if (!h) {
			return input;
		}

		var rgb = hexToRgb(h[0]);
		var rgb_chars = [rgb.r, rgb.g, rgb.b];
		var hexa = '';

		if (o) {
			rgb_chars.push(o[0]);
			hexa = 'rgba(' + rgb_chars.join(', ') + ')';
		} else {
			hexa = 'rgb(' + rgb_chars.join(', ') + ')';
		}

		var result = input.replace(HEX_ALPHA_RE, hexa);

		if (result.indexOf('hexa') === -1) {
			return result;
		} else {
			return recurse(result);
		}
	}
}
770840
def read_colormap(fh, byteorder, dtype, count, offsetsize):
    """"""
    cmap = fh.read_array(byteorder+dtype[-1], count)
    cmap.shape = (3, -1)
    return cmap
1272390
function color2hex6(color) {
	const named = namedColors[color.toLowerCase()]; if (named) { return '#'+ named; }
	const hex = (/^#([0-9A-Fa-f]{3,8})$/).exec(color); if (hex) {
		const c = hex[1]; if (c.length !== 5 && c.length !== 7) {
			return '#'+ (c.length < 6 ? c.split('').map(x => x+x).join('') : c).slice(0, 6);
		}
	}
	const rgb = (/^rgba?[(]([\d.e%+-]+)\s*(?:\s|,\s*)([\d.e%+-]+)\s*(?:\s|,\s*)([\d.e%+-]+)\s*(?:\s|,\s*)?.*?[)]$/).exec(color); if (rgb) {
		const r = parseNumber(rgb[1], 255), g = parseNumber(rgb[2], 255), b = parseNumber(rgb[3], 255);
		if (isFinite(r) && isFinite(g) && isFinite(b)) { return hexOf(r, g, b); }
	}
	const hsl = (/^hsla?[(]([\d.e+-]+)(|deg|rad|grad|turn)\s*(?:\s|,\s*)([\d.e+-]+[%])\s*(?:\s|,\s*)([\d.e+-]+[%])\s*(?:\s|,\s*)?.*?[)]$/).exec(color); if (hsl) {
		const h = parseNumber(hsl[1]) * hueMultiplier[hsl[2]], s = parseNumber(hsl[3], 100), l = parseNumber(hsl[4], 100);
		if (isFinite(h) && isFinite(s) && isFinite(l)) {
			const { r, g, b, } = hsl2rgb((h % 1 + 1) % 1, s < 0 ? 0 : s > 1 ? 1 : s, l < 0 ? 0 : l > 1 ? 1 : l);
			return hexOf(r, g, b);
		}
	}
	return null; // whatever
	function hexOf(r, g, b) {
		function clamp(n) { return (n < 0 ? 0 : n > 255 ? 255 : n |0).toString(16).padStart(2, '0'); }
		return '#'+ clamp(r) + clamp(g) + clamp(b);
	}
	function parseNumber(n, base) { return n[n.length - 1] === '%' ? n.slice(0, -1) / base : +n; }
	function hsl2rgb(h, s, l) { // basically from here: https://stackoverflow.com/a/9493060
		if (s === 0) { return { r: l * 256, g: l * 256, b: l * 256, }; } // achromatic
		const q = l < 0.5 ? l * (1 + s) : l + s - l * s, p = 2 * l - q;
		return {
			r: hue2rgb(p, q, h + 1/3) * 256,
			g: hue2rgb(p, q, h) * 256,
			b: hue2rgb(p, q, h - 1/3) * 256,
		};
		function hue2rgb(p, q, t) {
			if (t < 0) { t += 1; } if (t > 1) { t -= 1; }
			if (t < 1/6) { return p + (q - p) * 6 * t; }
			if (t < 1/2) { return q; }
			if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
			return p;
		}
	}
}
86802
def from_html(html_style_colour_str: str):
        
        html_style_colour_str = html_style_colour_str.lstrip("#")
        components = list(map("".join, zip(*[iter(html_style_colour_str)]*2)))
        return ColourData(*(int(colour, 16) for colour in components))
1063440
function convertColorComponent (input) {
  let result = input.toString(16);
  if (result.length < 2) {
    result = '0' + result
  }
  return result;
}
313901
function (r, g, b) {
            if (r > 255 || g > 255 || b > 255)
                throw "Invalid color component";
            return ((r << 16) | (g << 8) | b).toString(16);
        }
96136
function generateColorByName(str) {
    var hue = 0;
    for (var i = 0; i < str.length; i++) {
        hue = (hue * PRIME + str.charCodeAt(i)) % MASK;
    }
    hue = Math.floor(hue * PRIME) % MASK / MASK;
    var rgb = hslToRgb(hue, SATURATION, LIGHTNESS);
    return ('#' + rgb[0].toString(16) + rgb[1].toString(16) + rgb[2].toString(16)).toUpperCase();
}
529129
def colorize(string, stack):
  ''''''
  codes = optimize(stack)
  if len(codes):
    prefix = SEQ % ';'.join(map(str, codes))
    suffix = SEQ % STYLE.reset
    return prefix + string + suffix
  else:
    return string
904641
function convertHexToRGB(color) {
  if (color.length === 4) {
    let extendedColor = '#'
    for (let i = 1; i < color.length; i++)
      extendedColor += color.charAt(i) + color.charAt(i)
    color = extendedColor
  }

  const values = {
    r: parseInt(color.substr(1, 2), 16),
    g: parseInt(color.substr(3, 2), 16),
    b: parseInt(color.substr(5, 2), 16)
  }

  return `rgb(${values.r}, ${values.g}, ${values.b})`
}
1118744
function hexaToRgba(hex) {
  if (hex.length === 3) {
    hex += "f"
  }
  if (hex.length === 4) {
    var h0 = hex.charAt(0)
    var h1 = hex.charAt(1)
    var h2 = hex.charAt(2)
    var h3 = hex.charAt(3)
    hex = h0 + h0 + h1 + h1 + h2 + h2 + h3 + h3
  }
  if (hex.length === 6) {
    hex += "ff"
  }
  var rgb = []
  for (var i = 0, l = hex.length; i < l; i += 2) {
    rgb.push(Math.round(parseInt(hex.substr(i, 2), 16) / (i === 6 ? 255 : 1) * DECIMAL_PRECISION) / DECIMAL_PRECISION)
  }

  return color({r: rgb[0], g: rgb[1], b: rgb[2], a: rgb[3]}).rgbaString()
}
328524
def colorize(str, type)
      str = CGI.escapeHTML(str) if options[:html]
      if options[:plain] || !options[:color][type] || !inspector.colorize?
        str
      #
      # Check if the string color method is defined by awesome_print and accepts
      # html parameter or it has been overriden by some gem such as colorize.
      #
      elsif str.method(options[:color][type]).arity == -1 # Accepts html parameter.
        str.send(options[:color][type], options[:html])
      else
        str = %Q|<kbd style="color:#{options[:color][type]}">#{str}</kbd>| if options[:html]
        str.send(options[:color][type])
      end
    end
690761
public static String colorToHex(Color color) {
        return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
    }
780973
def hex_colors(self):
        
        hc = []

        for color in self.colors:
            h = '#' + ''.join('{0:>02}'.format(hex(c)[2:].upper())
                              for c in color)
            hc.append(h)

        return hc
735124
def color_hex(self):
        """"""
        def clamp(x):
            return max(0, min(int(x), 255))

        r, g, b = np.trunc(self.color_rgb * 255)
        return "#{0:02x}{1:02x}{2:02x}".format(clamp(r), clamp(g), clamp(b))
779537
function rgb2hex(rgb) {
      if (/^#[0-9A-F]{6}$/i.test(rgb)) {
        return rgb;
      }

      rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);

      if (rgb === null) {
        return 'N/A';
      }

      function hex(x) {
        return ('0' + parseInt(x).toString(16)).slice(-2);
      }

      return '#' + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
    }
105992
def create_colormap(palette):
    """"""
    from trollimage.colormap import Colormap
    fname = palette.get('filename', None)
    if fname:
        data = np.load(fname)
        cmap = []
        num = 1.0 * data.shape[0]
        for i in range(int(num)):
            cmap.append((i / num, (data[i, 0] / 255., data[i, 1] / 255.,
                                   data[i, 2] / 255.)))
        return Colormap(*cmap)

    colors = palette.get('colors', None)
    if isinstance(colors, list):
        cmap = []
        values = palette.get('values', None)
        for idx, color in enumerate(colors):
            if values:
                value = values[idx]
            else:
                value = idx / float(len(colors) - 1)
            cmap.append((value, tuple(color)))
        return Colormap(*cmap)

    if isinstance(colors, str):
        from trollimage import colormap
        import copy
        return copy.copy(getattr(colormap, colors))

    return None