Skip to content

Commit

Permalink
Merge pull request #12322 from uckelman/board_rounding
Browse files Browse the repository at this point in the history
Scale summed board locations instead of summing scaled board locations to reduce rounding error
  • Loading branch information
uckelman authored Jun 18, 2023
2 parents 1213581 + 84c509b commit 96101d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vassal-app/src/main/java/VASSAL/build/module/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -2719,12 +2719,15 @@ public Point getLocation(Board b, double zoom) {
*/
protected Point getLocation(int column, int row, double zoom) {
final Point p = new Point();
int dx = 0;
for (int x = 0; x < column; ++x) {
p.translate((int) Math.floor(zoom * boardWidths[x][row]), 0);
dx += boardWidths[x][row];
}
int dy = 0;
for (int y = 0; y < row; ++y) {
p.translate(0, (int) Math.floor(zoom * boardHeights[column][y]));
dy += boardHeights[column][y];
}
p.translate((int) round(zoom * dx), (int) round(zoom * dy));
return p;
}

Expand Down

0 comments on commit 96101d4

Please sign in to comment.