message: Fix line alignment of polygons
diff: @@ -3,6 +3,44 @@ import { earcut } from '@pixi/utils';
  import type { IShapeBuildCommand } from './IShapeBuildCommand';
  import type { Polygon } from '@pixi/math';
  +function fixOrientation(points: number[], hole = false)
  +{
  + const m = points.length;
  +
  + if (m < 6)
  + {
  + return;
  + }
  +
  + let area = 0;
  +
  + for (let i = 0, x1 = points[m - 2], y1 = points[m - 1]; i < m; i += 2)
  + {
  + const x2 = points[i];
  + const y2 = points[i + 1];
  +
  + area += (x2 - x1) * (y2 + y1);
  +
  + x1 = x2;
  + y1 = y2;
  + }
  +
  + if ((!hole && area > 0) || (hole && area <= 0))
  + {
  + const n = m / 2;
  +
  + for (let i = n + (n % 2); i < m; i += 2)
  + {
  + const i1 = m - i - 2;
  + const i2 = m - i - 1;
  + const i3 = i;
  + const i4 = i + 1;
  +
  + [points[i1], points[i3]] = [points[i3], points[i1]];
  + [points[i2], points[i4]] = [points[i4], points[i2]];
  + }
  + }
  +}
  /**
  * Builds a polygon to draw
  *
  @@ -30,6 +68,8 @@ export const buildPoly: IShapeBuildCommand = {
  if (points.length >= 6)
  {
  + fixOrientation(points, false);
  +
  const holeArray = [];
  // Process holes..
  @@ -37,6 +77,8 @@ export const buildPoly: IShapeBuildCommand = {
  {
  const hole = holes[i];
  + fixOrientation(hole.points, true);
  +
  holeArray.push(points.length / 2);
  points = points.concat(hole.points);
  }
  