zoukankan      html  css  js  c++  java
  • 十六进制颜色码转换成RGB颜色值

    ;(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;
    });
    author:Lik
    Endeavoring to powerless, struggling to move yourself.
  • 相关阅读:
    多态
    java8的十大新特性
    Floyd最短路径算法
    ES6(六)函数扩展
    ES6(五)数组扩展
    ES6(四)数值扩展
    ES6(一)解构赋值
    store封装
    ipad方案
    pyinstaller编译打包为pyd
  • 原文地址:https://www.cnblogs.com/likwin/p/7991651.html
Copyright © 2011-2022 走看看