lib/palette.js
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);
    }
  }
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);
    }
  }
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 ) ; } }
Attempt to parse color. Copied from Stylus source code.

@param {String} str
@return {RGBA}
@api private
Attempt to parse color . Copied from Stylus source code .