
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
import { __extends } from "tslib";
/**
 * Line path for bezier and straight line draw
 */
import * as graphic from '../../util/graphic.js';
var BgColorShape = /** @class */function () {
  function BgColorShape() {
    this.points = [];
    this.isLine = false;
    this.height = 2;
  }
  return BgColorShape;
}();
var BgColorPath = /** @class */function (_super) {
  __extends(BgColorPath, _super);
  function BgColorPath(opts) {
    var _this = _super.call(this, opts) || this;
    _this.type = 'BarPlot';
    return _this;
  }
  BgColorPath.prototype.getDefaultStyle = function () {
    return {
      stroke: 'none',
      fill: '#000'
    };
  };
  BgColorPath.prototype.getDefaultShape = function () {
    return new BgColorShape();
  };
  BgColorPath.prototype.buildPath = function (ctx, shape) {
    var points = shape.points,
      isLine = shape.isLine,
      height = shape.height,
      stroke = shape.stroke,
      isWebviewRender = shape.isWebviewRender,
      fill = shape.fill;
    if (isLine) {
      for (var index = 0; index < points.length; index++) {
        var point = points[index];
        var x = point.x,
          y = point.y;
        ctx.moveTo(x, y);
        ctx.lineTo(x, y + height);
        if (isWebviewRender && index % 5 === 0 && stroke) {
          ctx.strokeStyle(stroke);
          ctx.beginPathFill();
        }
      }
    } else {
      var nextIndex = 0;
      for (var index = 0; index < points.length; index++) {
        var point = points[index];
        var x = point.x,
          y = point.y;
        var width = point.width;
        nextIndex = index;
        var nextPoint = points[nextIndex + 1];
        while (nextPoint && nextPoint.x === x + width) {
          width = width + nextPoint.width;
          nextIndex++;
          nextPoint = points[nextIndex + 1];
        }
        ctx.rect(x, y, width, height);
        index = nextIndex;
        if (isWebviewRender && index % 5 === 0 && fill) {
          ctx.fillStyle(fill);
          ctx.beginPathFill();
        }
      }
    }
  };
  return BgColorPath;
}(graphic.Path);
export default BgColorPath;