Format color from r g b values - Node.js CSS

Node.js examples for CSS:Color

Description

Format color from r g b values

Demo Code


function format_color(r,g,b){
  var sr = "0" + parseInt(r).toString(16);
  var sg = "0" + parseInt(g).toString(16);
  var sb = "0" + parseInt(b).toString(16);
  sr = sr.substr(sr.length -2);//  ww w .ja  va2 s . c  o  m
  sg = sg.substr(sg.length -2);
  sb = sb.substr(sb.length -2);
  return ("#" + sr + sg + sb);
}

Related Tutorials