function parse(str) {
  if (isString(str)) {
    if (ColorNames.isColorName(str)) {
      str = ColorNames.getColorByName(str);
    }

    if (str.indexOf("rgb(") > -1) {
      var arr = str.replace("rgb(", "").replace(")", "").split(",");

      for (var i = 0, len = arr.length; i < len; i++) {
        arr[i] = parseInt(trim(arr[i]), 10);
      }

      var obj = { type: "rgb", r: arr[0], g: arr[1], b: arr[2], a: 1 };

      obj = { ...obj, ...RGBtoHSL(obj) };

      return obj;
    } else if (str.indexOf("rgba(") > -1) {
      var arr = str.replace("rgba(", "").replace(")", "").split(",");

      for (var i = 0, len = arr.length; i < len; i++) {
        if (len - 1 == i) {
          arr[i] = parseFloat(trim(arr[i]));
        } else {
          arr[i] = parseInt(trim(arr[i]), 10);
        }
      }

      var obj = { type: "rgb", r: arr[0], g: arr[1], b: arr[2], a: arr[3] };

      obj = { ...obj, ...RGBtoHSL(obj) };

      return obj;
    } else if (str.indexOf("hsl(") > -1) {
      var arr = str.replace("hsl(", "").replace(")", "").split(",");

      for (var i = 0, len = arr.length; i < len; i++) {
        arr[i] = parseFloat(trim(arr[i]));
      }

      var obj = { type: "hsl", h: arr[0], s: arr[1], l: arr[2], a: 1 };

      obj = { ...obj, ...HSLtoRGB(obj) };

      return obj;
    } else if (str.indexOf("hsla(") > -1) {
      var arr = str.replace("hsla(", "").replace(")", "").split(",");

      for (var i = 0, len = arr.length; i < len; i++) {
        if (len - 1 == i) {
          arr[i] = parseFloat(trim(arr[i]));
        } else {
          arr[i] = parseInt(trim(arr[i]), 10);
        }
      }

      var obj = { type: "hsl", h: arr[0], s: arr[1], l: arr[2], a: arr[3] };

      obj = { ...obj, ...HSLtoRGB(obj) };

      return obj;
    } else if (str.indexOf("#") == 0) {
      str = str.replace("#", "");
      var arr = [];
      var a = 1;
      if (str.length == 3) {
        for (var i = 0, len = str.length; i < len; i++) {
          var char = str.substr(i, 1);
          arr.push(parseInt(char + char, 16));
        }
      } else if (str.length === 8) {
        for (var i = 0, len = str.length; i < len; i += 2) {
          arr.push(parseInt(str.substr(i, 2), 16));
        }

        a = arr.pop() / 255;
      } else {
        for (var i = 0, len = str.length; i < len; i += 2) {
          arr.push(parseInt(str.substr(i, 2), 16));
        }
      }

      var obj = { type: "hex", r: arr[0], g: arr[1], b: arr[2], a };

      obj = { ...obj, ...RGBtoHSL(obj) };

      return obj;
    }
  } else if (isNumber(str)) {
    if (0x000000 <= str && str <= 0xffffff) {
      const r = (str & 0xff0000) >> 16;
      const g = (str & 0x00ff00) >> 8;
      const b = (str & 0x0000ff) >> 0;

      var obj = { type: "hex", r, g, b, a: 1 };
      obj = { ...obj, ...RGBtoHSL(obj) };
      return obj;
    } else if (0x00000000 <= str && str <= 0xffffffff) {
      const r = (str & 0xff000000) >> 24;
      const g = (str & 0x00ff0000) >> 16;
      const b = (str & 0x0000ff00) >> 8;
      const a = (str & 0x000000ff) / 255;

      var obj = { type: "hex", r, g, b, a };
      obj = { ...obj, ...RGBtoHSL(obj) };

      return obj;
    }
  }

  return str;
}
@method rgb

parse string to rgb color

		color.parse("#FF0000") === { r : 255, g : 0, b : 0 }
		color.parse("#FF0000FF") === { r : 255, g : 0, b : 0, a: 1 }

		color.parse("rgb(255, 0, 0)") == { r : 255, g : 0, b :0 }
		color.parse(0xff0000) == { r : 255, g : 0, b : 0 }
		color.parse(0xff000000) == { r : 255, g : 0, b : 0, a: 0 }

@param {String} str color string
@returns {Object}  rgb object