
/*
* 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";
/* global Float32Array */
// TODO Batch by color
import * as graphic from '../../util/graphic.js';
// 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 points = shape.points;
    var isShadow = shape.isShadow;
    var isWebviewRender = shape.isWebviewRender;
    var symbolProxy = this.symbolProxy;
    var symbolProxyShape = symbolProxy.shape;
    var lastColor = '';
    for (var i = 0; i < points.length; i++) {
      var _a = points[i],
        point = _a.point,
        color = _a.color;
      var size = isShadow ? points[i].size * 3 : points[i].size;
      var x = point[0],
        y = point[1];
      if (isNaN(x) || isNaN(y)) {
        continue;
      }
      var colorChanged = lastColor && lastColor !== color;
      if (colorChanged || isWebviewRender && i % 5 === 0) {
        path.fillStyle(lastColor);
        path.beginPathFill();
      }
      symbolProxyShape.x = x - size / 2;
      symbolProxyShape.y = y - size / 2;
      symbolProxyShape.width = size;
      symbolProxyShape.height = size;
      symbolProxy.buildPath(path, symbolProxyShape, true);
      // path.closePath();
      // path.fillStyle(color);
      if (lastColor !== color) {
        lastColor = color;
      }
    }
    if (lastColor) {
      path.fillStyle(lastColor);
    }
  };
  return SymbolPath;
}(graphic.Path);
export default SymbolPath;