Skip to content

Commit

Permalink
Better pixel rounding for Firefox.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Bostock committed Aug 20, 2010
1 parent bc483d0 commit 73168a7
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
8 changes: 4 additions & 4 deletions polymaps.js
Expand Up @@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){

po.version = "2.0.1"; // semver.org
po.version = "2.0.2"; // semver.org

var zero = {x: 0, y: 0};
po.id = (function() {
Expand Down Expand Up @@ -673,7 +673,7 @@ po.layer = function(load, unload) {

// set the layer transform
container.setAttribute("transform",
"translate(" + mapSize.x / 2 + "," + mapSize.y / 2 + ")"
"translate(" + (mapSize.x >> 1) + "," + (mapSize.y >> 1) + ")"
+ (mapAngle ? "rotate(" + mapAngle / Math.PI * 180 + ")" : "")
+ (mapZoomFraction ? "scale(" + Math.pow(2, mapZoomFraction) + ")" : "")
+ (transform ? transform.zoomFraction(mapZoomFraction) : ""));
Expand All @@ -686,8 +686,8 @@ po.layer = function(load, unload) {

// round to pixel boundary to avoid anti-aliasing artifacts
if (!transform && !mapAngle && !mapZoomFraction) {
tileCenter.column = (Math.round(tileSize.x * tileCenter.column) + (mapSize.x & 1) / 2) / tileSize.x;
tileCenter.row = (Math.round(tileSize.y * tileCenter.row) + (mapSize.y & 1) / 2) / tileSize.y;
tileCenter.column = Math.round(tileSize.x * tileCenter.column) / tileSize.x;
tileCenter.row = Math.round(tileSize.y * tileCenter.row) / tileSize.y;
}

// layer-specific zoom transform
Expand Down

0 comments on commit 73168a7

Please sign in to comment.