Helper function to get arguments for color manipulation functions.
takes a list that contains a color like thing and a percentage.
334678
protected function colorArgs($args)
    {
        if ($args[0] != 'list' || count($args[2]) < 2) {
            return array(array('color', 0, 0, 0), 0);
        }
        list($color, $delta) = $args[2];
        $color = $this->assertColor($color);
        $delta = floatval($delta[1]);

        return array($color, $delta);
    }
1284934
def _short_color_list(self):
        """"""
        return [c for c in colors.get_colors() if not re.search(r'\d', c)]
1073925
def items(cls):
        
        return [
            cls.GREEN,
            cls.BLACK_AND_WHITE,
            cls.CONTRAST_SHIFTED,
            cls.CONTRAST_CONTINUOUS
        ]
474884
function colorLines(name, str) {
  return str
    .split('\n')
    .map(function(str) {
      return color(name, str);
    })
    .join('\n');
}
216482
def add_colors(*args):
    '''  '''
    # Adapted from an answer here: http://stackoverflow.com/questions/14180866/sum-each-value-in-a-list-of-tuples
    added = [sum(x) for x in zip(*args)]
    return numpy.clip(added, 0, 255)
332761
def colorize(string, color, *args, **kwargs):
    
    string = string.format(*args, **kwargs)
    return color + string + colorama.Fore.RESET
633308
function plugin(palettes) {
  /**
   * Attempt to parse color. Copied from Stylus source code.
   *
   * @param {String} str
   * @return {RGBA}
   * @api private
   */
  var parseColor = 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);
    }
  };

  return function (style) {
    var getColor = function (paletteName, colorName) {
      var paletteName = paletteName.toString();
      var colorName = (new nodes.Literal(colorName)).toString().string;
      var color = parseColor(palettes[paletteName][colorName]);

      return color;
    };
    var getPalette = function (paletteName) {
      return function (colorName) {
        return getColor(paletteName, colorName);
      }
    };

    style.define('palette', getColor);

    // Construct custom functions for every palette
    Object.keys(palettes).forEach(function (paletteName) {
      style.define(['palette', paletteName].join('-'), getPalette(paletteName));
    });
  };
}
16569
function getColourAt(gradient, p) {
  p = clamp(p, 0, 0.9999);  // FIXME
  let r = Math.floor(p * (gradient.length - 1));
  let q = p * (gradient.length - 1) - r;
  return Colour.mix(gradient[r + 1], gradient[r], q);
}
744229
def _saturation(color, **kwargs):
    
    s = colorsys.rgb_to_hls(*[x / 255.0 for x in color.value[:3]])[2]
    return NumberValue((s * 100, '%'))
1030033
function(H, S, L) {
    H /= 360;

    var q = L < 0.5 ? L * (1 + S) : L + S - L * S;
    var p = 2 * L - q;

    return [H + 1/3, H, H - 1/3].map(function(color) {
        if(color < 0) {
            color++;
        }
        if(color > 1) {
            color--;
        }
        if(color < 1/6) {
            color = p + (q - p) * 6 * color;
        } else if(color < 0.5) {
            color = q;
        } else if(color < 2/3) {
            color = p + (q - p) * 6 * (2/3 - color);
        } else {
            color = p;
        }
        return Math.round(color * 255);
    });
}
103266
def calculate_colors(self, values):
        """"""
        # set domain if it is not set
        _flattenedList = list(flatten(values))
        if not self.is_domain_set:
            self.set_domain(_flattenedList)

        _flattenedColors = range(len(_flattenedList))
        for count, value in enumerate(_flattenedList):
            _flattenedColors[count] = self.calculate_color(value)

        return unflatten(values, iter(_flattenedColors))
318236
function createArgs(args, color) {
  var last = args[args.length - 1];
  if (args.length > 1 && isObject(last && last.hash)) {
    args.pop();
  }
  if (typeof color === 'string' && utils[color]) {
    args[0] = utils[color](args[0]);
  }
  return args;
}
1276374
function get(format) {
		var ret;

		// it's NaN if gradient colors on a column chart
		if (rgba && !isNaN(rgba[0])) {
			if (format === 'rgb') {
				ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
			} else if (format === 'a') {
				ret = rgba[3];
			} else {
				ret = 'rgba(' + rgba.join(',') + ')';
			}
		} else {
			ret = input;
		}
		return ret;
	}
233769
def :
    
    # All argument types must be str.
    rtext = [str(f) for f in text]

    return COLORIZE_FORMAT.format(
        _to_int(bg), _to_int(base), _to_int(fg), ''.join(rtext)
    )
182486
function get(format) {
		var ret;

		if (stops) {
			ret = merge(input);
			ret.stops = [].concat(ret.stops);
			each(stops, function (stop, i) {
				ret.stops[i] = [ret.stops[i][0], stop.get(format)];
			});

		// it's NaN if gradient colors on a column chart
		} else if (rgba && !isNaN(rgba[0])) {
			if (format === 'rgb') {
				ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
			} else if (format === 'a') {
				ret = rgba[3];
			} else {
				ret = 'rgba(' + rgba.join(',') + ')';
			}
		} else {
			ret = input;
		}
		return ret;
	}
758395
function(color1, color2) {
		var result = color1.slice();
		for (var i=0;i<3;i++) {
			for (var j=1;j<arguments.length;j++) {
				result[i] += arguments[j][i];
			}
		}
		return result;
	}
752010
def get_color_func(self, word):
        """"""
        try:
            color_func = next(
                color_func for (color_func, words) in self.color_func_to_words
                if word in words)
        except StopIteration:
            color_func = self.default_color_func

        return color_func