function format(obj, type, defaultColor = "rgba(0, 0, 0, 0)") {
  if (Array.isArray(obj)) {
    obj = { r: obj[0], g: obj[1], b: obj[2], a: obj[3] };
  }

  if (type == "hex") {
    return hex(obj);
  } else if (type == "rgb") {
    return rgb(obj, defaultColor);
  } else if (type == "hsl") {
    return hsl(obj);
  }

  return obj;
}
@method format

convert color to format string

```js
    ## hex
    color.format({ r : 255, g : 255, b : 255 }, 'hex')

    ## rgb
    color.format({ r : 255, g : 255, b : 255 }, 'rgb')

    ## rgba
    color.format({ r : 255, g : 255, b : 255, a : 0.5 }, 'rgb')
```

@param {Object} obj  obj has r, g, b and a attributes
@param {hex|rgb|hsl} type  format string type
@returns {*}