# all files / ol/style/ fill.js

95.24% Statements 20/21
88.89% Branches 16/18
100% Functions 5/5
95.24% Lines 20/21

    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
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    861×

    1×
    1×

    1×

    441×

    441×

    441×

    1×
    16×
    16×

    1×
    5856×

    1×
    7×
    7×

    1×
    28×
    22×

    22×

    28×

     goog.provide('ol.style.Fill');

    goog.require('ol');
    goog.require('ol.color');

    /**
     * @classdesc
     * Set fill style for vector features.
     *
     * @constructor
     * @param {olx.style.FillOptions=} opt_options Options.
     * @api
     */
    ol.style.Fill = function(opt_options) {

      var options = opt_options || {};

      /**
       * @private
       * @type {ol.Color|ol.ColorLike}
       */
      this.color_ = options.color !== undefined ? options.color : null;

      /**
       * @private
       * @type {string|undefined}
       */
      this.checksum_ = undefined;
    };

    /**
     * Clones the style. The color is not cloned if it is an {@link ol.ColorLike}.
     * @return {ol.style.Fill} The cloned style.
     * @api
     */
    ol.style.Fill.prototype.clone = function() {
      var color = this.getColor();
      return new ol.style.Fill({
        color: (color && color.slice) ? color.slice() : color || undefined
      });
    };

    /**
     * Get the fill color.
     * @return {ol.Color|ol.ColorLike} Color.
     * @api
     */
    ol.style.Fill.prototype.getColor = function() {
      return this.color_;
    };

    /**
     * Set the color.
     *
     * @param {ol.Color|ol.ColorLike} color Color.
     * @api
     */
    ol.style.Fill.prototype.setColor = function(color) {
      this.color_ = color;
      this.checksum_ = undefined;
    };

    /**
     * @return {string} The checksum.
     */
    ol.style.Fill.prototype.getChecksum = function() {
      if (this.checksum_ === undefined) {
        Iif (
          this.color_ instanceof CanvasPattern ||
            this.color_ instanceof CanvasGradient
        ) {
          this.checksum_ = ol.getUid(this.color_).toString();
        } else {
          this.checksum_ = 'f' + (this.color_ ?
            ol.color.asString(this.color_) : '-');
        }
      }

      return this.checksum_;
    };