# all files / ol/ colorlike.js

100% Statements 8/8
100% Branches 5/5
100% Functions 2/2
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    311×

    1×

    1×
    13917×
    13655×

    262×

    1×
    13917×

     goog.provide('ol.colorlike');

    goog.require('ol.color');

    /**
     * @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 ol.color.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
      );
    };