'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _color = require('./color.js');

var _color2 = _interopRequireDefault(_color);

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

var _ol_colorlike_ = {};

/**
 * @param {ol.Color|ol.ColorLike} color Color.
 * @return {ol.ColorLike} The color as an ol.ColorLike
 * @api
 */
_ol_colorlike_.asColorLike = function (color) {
  if (_ol_colorlike_.isColorLike(color)) {
    return (/** @type {string|CanvasPattern|CanvasGradient} */color
    );
  } else {
    return _color2.default.asString( /** @type {ol.Color} */color);
  }
};

/**
 * @param {?} color The value that is potentially an ol.ColorLike
 * @return {boolean} Whether the color is an ol.ColorLike
 */
_ol_colorlike_.isColorLike = function (color) {
  return typeof color === 'string' || color instanceof CanvasPattern || color instanceof CanvasGradient;
};
exports.default = _ol_colorlike_;
module.exports = exports['default'];