Created
September 14, 2015 02:21
-
-
Save xwartz/87298970b543e4ac128d to your computer and use it in GitHub Desktop.
颜色从十六进制转为 rgba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 颜色 从十六进制转为 rgba | |
exports.convertHex = function(hex, opacity) { | |
hex = hex.replace('#', ''); | |
r = parseInt(hex.substring(0, 2), 16); | |
g = parseInt(hex.substring(2, 4), 16); | |
b = parseInt(hex.substring(4, 6), 16); | |
result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')'; | |
return result; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment