#7361·phaser

WebGL stroke of a Polygon drops a vertex when its origin-shifted position equals the previous raw vertex

Author: DainDwarfCreated Sep 4, 2026Updated Sep 7, 2026

Version: Phaser 4.2.1; the code is unchanged on master. Not present in 3.x, whose StrokePathWebGL has no duplicate-point check. WebGL renderer only (the Canvas renderer strokes the full path).

Repro:

javascript
// A 6px diamond, centred by the default origin. Its stroke reaches three of the four
// corners and cuts across the fill; the fill itself is whole.
this.add.polygon(400, 300, [3, 0, 6, 3, 3, 6, 0, 3], 0x7d9c55)
  .setStrokeStyle(1, 0x000000)
  .setScale(20);

Any centred diamond does it, whatever its size or the order of its corners.

Cause: in src/gameobjects/shape/StrokePathWebGL.js, the loop that builds pointPath skips a point it takes for a repeat of the previous one:

javascript
var x = path[i] - dx;
var y = path[i + 1] - dy;
if (i > 0)
{
    if (x === path[i - 2] && y === path[i - 1])
    {
        // Duplicate point, skip it
        continue;
    }
}

x and y have the display origin (dx, dy) subtracted; path[i - 2] and path[i - 1] have not. So the test fires whenever a vertex lies exactly (dx, dy) past the previous one, which is true of one edge of every centred diamond, and it never catches a genuinely repeated vertex unless dx and dy are both zero.

Fix: compare against the previous shifted point, e.g. the last entry pushed to pointPath, or against path[i - 2] - dx and path[i - 1] - dy.

Workaround: a Rectangle turned 45° draws the same diamond with a closed stroke; its path never meets the condition.