Proper rounding for possibly negative numbers

This commit is contained in:
Andreas Hocevar
2016-01-11 16:12:33 +01:00
parent 7a644730a5
commit a3147c5d08
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;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB