"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.colorToHexNumber = colorToHexNumber;
exports.colorToHex = colorToHex;
exports.getColor = getColor;
exports.getColorAlpha = getColorAlpha;

var _isString2 = _interopRequireDefault(require("lodash/isString"));

var _isNumber2 = _interopRequireDefault(require("lodash/isNumber"));

var _color = _interopRequireDefault(require("color"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DEFAULT_COLOR = 0x000000;
/**
 * convert color string or number to hex number for pixi.js
 * @param  {string | number} color
 * @returns {number} hex number
 */

function colorToHexNumber(color) {
  return getColor(color).rgbNumber();
}
/**
 * convert color string or number to hex string
 * @param  {string | number} color
 * @returns {number} hex
 */


function colorToHex(color) {
  return getColor(color).hex();
}
/**
 * get Color instance
 * @param  {string | number} color
 * @returns {Color}
 */


function getColor(color) {
  return (0, _color.default)(color || DEFAULT_COLOR);
}
/**
 * get Color alpha
 * @param  {string | number} color
 * @returns {number}
 */


function getColorAlpha(color) {
  return (0, _isNumber2.default)(color) || (0, _isString2.default)(color) ? getColor(color).alpha() : 0;
}