;(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 = {
getRGB: function (hex) {
var rgb = [0, 0, 0];
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;
});
介绍了一个名为 LikWin 的色彩转换工具,该工具能够将十六进制颜色代码转换为 RGB 和 RGBA 格式,适用于前端开发中颜色值的处理。
801

被折叠的 条评论
为什么被折叠?



