You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WebGL stroke of a Polygon drops a vertex when its origin-shifted position equals the previous raw vertex #7361
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:
// 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:
varx=path[i]-dx;vary=path[i+1]-dy;if(i>0){if(x===path[i-2]&&y===path[i-1]){// Duplicate point, skip itcontinue;}}
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.
Activity
photonstorm commentedon Sep 7, 2026
This issue has been mentioned on Phaser. There might be relevant details there:
https://phaser.discourse.group/t/problem-with-phaser-4-rectangles/15652/7