Skip to content

Commit 7e3e3f3

Browse files
hansonrhansonr
authored andcommitted
fixes antialias issue with JSGraphics2D.fillPoly
1 parent 7330d1c commit 7e3e3f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ public void fillPolygon(int[] axPoints, int[] ayPoints, int nPoints) {
259259
*/
260260
private void doPoly(int[] axPoints, int[] ayPoints, int nPoints, boolean fill) {
261261
ctx.beginPath();
262-
ctx.translate(0.5, 0.5);
262+
if (!fill)
263+
ctx.translate(0.5, 0.5);
263264
ctx.moveTo(axPoints[0], ayPoints[0]);
264265
for (int i = 1; i < nPoints; i++) {
265266
ctx.lineTo(axPoints[i], ayPoints[i]);
@@ -269,8 +270,8 @@ private void doPoly(int[] axPoints, int[] ayPoints, int nPoints, boolean fill) {
269270
ctx.fill();
270271
} else {
271272
ctx.stroke();
273+
ctx.translate(-0.5, -0.5);
272274
}
273-
ctx.translate(-0.5, -0.5);
274275
}
275276

276277
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {

0 commit comments

Comments
 (0)