
/*
* 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 { __assign, __extends } from "tslib";
/* global Float32Array */
// TODO Batch by color
import * as graphic from '../../util/graphic.js';
// const variableTypes = ['labelCenter', 'labelDown', 'labelUp', 'labelLeft', 'labelRight', 'labelLowerLeft',
//     'labelLowerRight', 'labelUpperLeft', 'labelUpperRight', 'arrowUp', 'arrowDown'];
// const BOOST_SIZE_THRESHOLD = 4;
var LargeSymbolPathShape = /** @class */function () {
  function LargeSymbolPathShape() {}
  return LargeSymbolPathShape;
}();
var SymbolPath = /** @class */function (_super) {
  __extends(SymbolPath, _super);
  // private _ctx: CanvasRenderingContext2D;
  function SymbolPath(opts) {
    return _super.call(this, opts) || this;
  }
  SymbolPath.prototype.getDefaultShape = function () {
    return new LargeSymbolPathShape();
  };
  SymbolPath.prototype.buildPath = function (path, shape) {
    var _a;
    var points = shape.points;
    var symbolProxy = this.symbolProxy;
    var symbolProxyShape = symbolProxy.shape;
    var needCenter = (_a = shape.needCenter) !== null && _a !== void 0 ? _a : true;
    var isWebviewRender = shape.isWebviewRender;
    var isLine = shape.isLine;
    var lastColor = '';
    for (var i = 0; i < points.length; i++) {
      var _b = points[i],
        point = _b.point,
        color = _b.color,
        size = _b.size,
        _c = _b.offset,
        offset = _c === void 0 ? [0, 0] : _c;
      var width = size[0],
        height = size[1];
      var x = point[0],
        y = point[1];
      if (isNaN(x) || isNaN(y)) {
        continue;
      }
      // const isNextSameColor = points[i + 1] && color === points[i + 1].color;
      // const isPrevSameColor = points[i - 1] && color === points[i - 1].color;
      var colorChanged = lastColor && lastColor !== color;
      var xOffset = offset[0],
        yOffset = offset[1];
      if (colorChanged || isWebviewRender && i % 5 === 0) {
        isLine ? path.strokeStyle(lastColor) : path.fillStyle(lastColor);
        path.beginPathFill();
      }
      symbolProxyShape.x = x - (needCenter ? width / 2 : 0) + xOffset;
      symbolProxyShape.y = y - (needCenter ? height / 2 : 0) + yOffset;
      // symbolProxyShape.y = y + yOffset;
      symbolProxyShape.width = width;
      symbolProxyShape.height = height;
      symbolProxy.buildPath(path, __assign(__assign({}, symbolProxyShape), points[i].shape), true);
      if (lastColor !== color) {
        lastColor = color;
      }
      // path.closePath();
      // isLine ? path.strokeStyle(color) : path.fillStyle(color);
    }

    if (lastColor) {
      isLine ? path.strokeStyle(lastColor) : path.fillStyle(lastColor);
    }
  };
  return SymbolPath;
}(graphic.Path);
export default SymbolPath;