|
|
@ -71,6 +71,7 @@ var cache = {}; |
|
|
|
var parseColor = exports.parseColor = function(str){ |
|
|
|
if (cache[str]) return cache[str]; |
|
|
|
str = colors[str] || String(str); |
|
|
|
// RGBA
|
|
|
|
if (0 == str.indexOf('rgba')) { |
|
|
|
var captures = /rgba\((\d{1,3}) *, *(\d{1,3}) *, *(\d{1,3}) *, *(\d+\.\d+|\.\d+|\d+) *\)/.exec(str); |
|
|
|
if (!captures) return; |
|
|
@ -80,6 +81,7 @@ var parseColor = exports.parseColor = function(str){ |
|
|
|
, parseInt(captures[3], 10) |
|
|
|
, parseFloat(captures[4], 10) |
|
|
|
]; |
|
|
|
// RGB
|
|
|
|
} else if (0 == str.indexOf('rgb')) { |
|
|
|
var captures = /rgb\((\d{1,3}) *, *(\d{1,3}) *, *(\d{1,3}) *\)/.exec(str); |
|
|
|
if (!captures) return; |
|
|
@ -89,6 +91,7 @@ var parseColor = exports.parseColor = function(str){ |
|
|
|
, parseInt(captures[3], 10) |
|
|
|
, 1 |
|
|
|
]; |
|
|
|
// #RRGGBB
|
|
|
|
} else if ('#' == str.charAt(0) && str.length > 4) { |
|
|
|
var captures = /#(\w{2})(\w{2})(\w{2})/.exec(str); |
|
|
|
if (!captures) return; |
|
|
@ -98,6 +101,7 @@ var parseColor = exports.parseColor = function(str){ |
|
|
|
, parseInt(captures[3], 16) |
|
|
|
, 1 |
|
|
|
]; |
|
|
|
// #RGB
|
|
|
|
} else if ('#' == str.charAt(0)) { |
|
|
|
var captures = /#(\w)(\w)(\w)/.exec(str); |
|
|
|
if (!captures) return; |
|
|
|