Merge pull request #4647 from ahocevar/snap-round-to-pixel

Proper rounding for possibly negative numbers
This commit is contained in:
Andreas Hocevar
2016-01-11 16:34:24 +01:00
3 changed files with 4 additions and 4 deletions

View File

@@ -274,8 +274,8 @@ ol.render.canvas.Immediate.prototype.drawImages_ =
var x = pixelCoordinates[i] - this.imageAnchorX_;
var y = pixelCoordinates[i + 1] - this.imageAnchorY_;
if (this.imageSnapToPixel_) {
x = (x + 0.5) | 0;
y = (y + 0.5) | 0;
x = Math.round(x);
y = Math.round(y);
}
if (rotation !== 0 || this.imageScale_ != 1) {
var centerX = x + this.imageAnchorX_;

View File

@@ -329,8 +329,8 @@ ol.render.canvas.Replay.prototype.replay_ = function(
x = pixelCoordinates[d] - anchorX;
y = pixelCoordinates[d + 1] - anchorY;
if (snapToPixel) {
x = (x + 0.5) | 0;
y = (y + 0.5) | 0;
x = Math.round(x);
y = Math.round(y);
}
if (scale != 1 || rotation !== 0) {
var centerX = x + anchorX;