
/*
* 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.
 */

import { __extends } from "tslib";
import Path from 'tvrender/lib/graphic/Path.js';
var BarPathShape = /** @class */function () {
  function BarPathShape() {}
  return BarPathShape;
}();
var BarPath = /** @class */function (_super) {
  __extends(BarPath, _super);
  function BarPath(opts) {
    var _this = _super.call(this, opts) || this;
    _this.type = 'BarPath';
    return _this;
  }
  BarPath.prototype.getDefaultShape = function () {
    return new BarPathShape();
  };
  BarPath.prototype.buildPath = function (ctx, shape) {
    var typeArray = shape.typeArray,
      isSimpleBox = shape.isSimpleBox,
      candleWidth = shape.candleWidth,
      isWebviewRender = shape.isWebviewRender,
      stroke = shape.stroke,
      ishlc = shape.ishlc,
      _a = shape.offset,
      offset = _a === void 0 ? 0 : _a;
    var points = typeArray.buffer();
    var len = typeArray.length();
    var width = Math.floor(candleWidth / 2) + 0.5;
    for (var i = 0; i < len;) {
      var x1 = points[i++] + offset;
      var y1 = points[i++];
      var x2 = points[i++] + offset;
      var y2 = points[i++];
      var x3 = points[i++];
      var y3 = points[i++];
      var x4 = points[i++];
      var y4 = points[i++];
      if (isSimpleBox) {
        ctx.moveTo(x3, y3);
        ctx.lineTo(x3, y4);
      } else {
        ctx.moveTo(x3, y3);
        ctx.lineTo(x4, y4);
        if (!ishlc) {
          ctx.moveTo(x1, y1);
          ctx.lineTo(x1 - width, y1);
        }
        ctx.moveTo(x2, y2);
        ctx.lineTo(x2 + width, y2);
      }
      if (isWebviewRender && i % (8 * 5) === 0 && stroke) {
        ctx.strokeStyle(stroke);
        ctx.beginPathFill();
      }
    }
  };
  return BarPath;
}(Path);
export default BarPath;