feature : zoom level : code review

+ Switched from BITWISE OR 0 (x | 0) to Math.floor for readability
This commit is contained in:
jdescottes 2013-11-15 00:39:43 +01:00
parent 3af64d3f45
commit e68ae7f31d
2 changed files with 4 additions and 4 deletions

View File

@ -207,8 +207,8 @@
y = y + this.offset.y * cellSize;
return {
x : (x / cellSize) | 0,
y : (y / cellSize) | 0
x : Math.floor(x / cellSize),
y : Math.floor(y / cellSize)
};
};

View File

@ -46,13 +46,13 @@
// Draw the zoomed-up pixels to a different canvas context
for (var x = 0; x < source.width; x++) {
// Calculate X Range
xRange = (((x + 1) * zoom) | 0) - xOffset;
xRange = Math.floor((x + 1) * zoom) - xOffset;
for (var y = 0; y < source.height; y++) {
// Calculate Y Range
if (!yRanges[y + ""]) {
// Cache Y Range
yRanges[y + ""] = (((y + 1) * zoom) | 0) - yOffset;
yRanges[y + ""] = Math.floor((y + 1) * zoom) - yOffset;
}
yRange = yRanges[y + ""];