/**
 * transform rgba() to hexadecimal.
 *
 * @param  {String} string declaration value
 * @return {String}        converted declaration value to hexadecimal
 */
function transformRgba(string) {
  var value = RGBA.exec(string)
  if (!value) {
    return
  }

  var rgb = colorString.getRgb(value[0])
  var hex = colorString.hexString(rgb)
  hex = string.replace(RGBA, hex)

  return (hex)
}
示例#2
0
function makeImage(data, cb) {
   imageTemplate = dot.template(''+(data.template || template));
   data.colorscheme = data.colorscheme.split(",");
   data.image = data.image || undefined;
  if (data.colorscheme) {
    data.colorA =  color.hexString(color.getRgb(data.colorscheme[0]));
	if(data.colorscheme.length > 1){
		data.colorB =  color.hexString(color.getRgb(data.colorscheme[1]));
	}else{
		data.colorB =  color.hexString(color.getRgb(data.colorscheme[0]));
	}
  }
  if(data.font){
	data.fontColor = color.hexString(color.getRgb(data.font));
  }
  data.widths = [
    (canvasContext.measureText(data.text[0]).width|0) + 10,
    (canvasContext.measureText(data.text[1]).width|0) + 10,
  ];
  var result = imageTemplate(data);
  // Run the SVG through SVGO.
  optimize(result, function(object) { cb(object.data); });
}