
/*
* 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 { __spreadArray } from "tslib";
/* global Float32Array */
import createRenderPlanner from '../helper/createRenderPlanner.js';
import { getDrawLine } from '../mineLines/util.js';
import { error } from '../../util/log.js';
function optimizePoint(point1, point2, lineWidth) {
  var notOptimize = lineWidth % 2 === 0;
  if (notOptimize) {
    return;
  }
  if (point1[0] === point2[0]) {
    point2[0] = point1[0] = Math.floor(point1[0]) + 0.5;
  }
  if (point1[1] === point2[1]) {
    point2[1] = point1[1] = Math.floor(point1[1]) + 0.5;
  }
}
var LineFillsLayout = {
  seriesType: 'lineFills',
  plan: createRenderPlanner(),
  reset: function (seriesModel, ecModel, api) {
    var coordSys = seriesModel.coordinateSystem;
    if (!coordSys) {
      if (process.env.NODE_ENV !== 'production') {
        error('The lines series must have a coordinate system.');
      }
      return;
    }
    var data = seriesModel.getData();
    var width = api.getWidth();
    var height = api.getHeight();
    return {
      progress: function (params, mineLinesData) {
        // const store = mineLinesData.getStore();
        var linesPoints = [];
        for (var i = params.start; i < params.end; i++) {
          var itemModel = data.getItemModel(i);
          var color = itemModel.get('itemStyle').color;
          if (!color) {
            continue;
          }
          var line1 = itemModel.get('line1');
          var startPoint1 = coordSys.dataToPoint([line1.value[0], line1.value[2]]);
          var endPoint1 = coordSys.dataToPoint([line1.value[1], line1.value[3]]);
          optimizePoint(startPoint1, endPoint1, line1.itemStyle.width);
          var _a = getDrawLine({
              width: width,
              height: height,
              extend: line1.itemStyle.extend,
              startPoint: startPoint1,
              endPoint: endPoint1
            }),
            extendStart1 = _a[0],
            extendEnd1 = _a[1];
          var line2 = itemModel.get('line2');
          var startPoint2 = coordSys.dataToPoint([line2.value[0], line2.value[2]]);
          var endPoint2 = coordSys.dataToPoint([line2.value[1], line2.value[3]]);
          optimizePoint(startPoint2, endPoint2, line2.itemStyle.width);
          var _b = getDrawLine({
              width: width,
              height: height,
              extend: line2.itemStyle.extend,
              startPoint: startPoint2,
              endPoint: endPoint2
            }),
            extendStart2 = _b[0],
            extendEnd2 = _b[1];
          var points = [];
          points.push.apply(points, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], extendStart1, false), extendEnd1, false), extendEnd2, false), extendStart2, false));
          linesPoints.push({
            color: color,
            points: points
          });
        }
        data.setLayout({
          linesPoints: linesPoints
        });
      }
    };
  }
};
export default LineFillsLayout;