首页 > 其他 > 详细

十六进制颜色码转换成RGB颜色值

时间:2017-12-06 12:46:02      阅读:237      评论:0      收藏:0      [点我收藏+]
;(function (name, context, factory) {
// Supports UMD. AMD, CommonJS/Node.js and browser context
if (typeof module !== "undefined" && module.exports) {
module.exports = factory();
} else if (typeof define === "function" && define.amd) {
define(factory);
} else {
context[name] = factory();
}
})(‘LikWin‘, window, function () {
‘use strict‘;
var LikWin = {
getRGBA: function (hex) {
var rgb = [0, 0, 0, a];
if (/#(..)(..)(..)/g.test(hex)) {
rgb = [parseInt(RegExp.$1, 16), parseInt(RegExp.$2, 16), parseInt(RegExp.$3, 16)];
};
return "rgb(" + rgb.join(",") + ")";
},
getRGBA: function (hex, a) {
var rgb = [0, 0, 0, a];
if (/#(..)(..)(..)/g.test(hex)) {
rgb = [parseInt(RegExp.$1, 16), parseInt(RegExp.$2, 16), parseInt(RegExp.$3, 16)];
};
return "rgba(" + rgb.join(",") + ", " + a + ")";
}
};
return LikWin;
});

十六进制颜色码转换成RGB颜色值

原文:http://www.cnblogs.com/likwin/p/7991651.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!