Skip to content

Commit 1a125d1

Browse files
committed
sprite func pixel offset
1 parent 8ffffed commit 1a125d1

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

src/com/thomasdiewald/liquidfun/java/DwUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ static public PImage createSprite(PApplet papplet, int size, float exp1, float e
256256
for(int x = 0; x < size; x++){
257257
int pid = y * size + x;
258258

259-
float xn = (x / (float)size) * 2f - 1f;
260-
float yn = (y / (float)size) * 2f - 1f;
259+
float xn = ((x+0.5f) / (float)size) * 2f - 1f;
260+
float yn = ((y+0.5f) / (float)size) * 2f - 1f;
261261
float dd = (float) Math.sqrt(xn*xn + yn*yn);
262262

263263
dd = DwUtils.clamp(dd, 0, 1);
@@ -308,8 +308,7 @@ static public PGraphics2D createCheckerBoard(PApplet papplet, int dimx, int dimy
308308
}
309309

310310
pg.endDraw();
311-
312-
311+
313312
return pg;
314313
}
315314

0 commit comments

Comments
 (0)