String to Color Array - Node.js CSS

Node.js examples for CSS:Color

Description

String to Color Array

Demo Code

String.prototype.toColorArray = function() {

  var x = /#([a-gA-G0-9]{2})([a-gA-G0-9]{2})([a-gA-G0-9]{2})/;

  var a = x.exec( this.toString() ).slice(1);

  for (var i = 0; i < a.length; i++) {
    a[i] = parseInt( a[i], 16 );/*from ww  w . j  ava2 s. c o  m*/
  }

  return a;
};

Related Tutorials