mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
feature : zoom level : code review
+ Switched from BITWISE OR 0 (x | 0) to Math.floor for readability
This commit is contained in:
@@ -207,8 +207,8 @@
|
|||||||
y = y + this.offset.y * cellSize;
|
y = y + this.offset.y * cellSize;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x : (x / cellSize) | 0,
|
x : Math.floor(x / cellSize),
|
||||||
y : (y / cellSize) | 0
|
y : Math.floor(y / cellSize)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -46,13 +46,13 @@
|
|||||||
// Draw the zoomed-up pixels to a different canvas context
|
// Draw the zoomed-up pixels to a different canvas context
|
||||||
for (var x = 0; x < source.width; x++) {
|
for (var x = 0; x < source.width; x++) {
|
||||||
// Calculate X Range
|
// Calculate X Range
|
||||||
xRange = (((x + 1) * zoom) | 0) - xOffset;
|
xRange = Math.floor((x + 1) * zoom) - xOffset;
|
||||||
|
|
||||||
for (var y = 0; y < source.height; y++) {
|
for (var y = 0; y < source.height; y++) {
|
||||||
// Calculate Y Range
|
// Calculate Y Range
|
||||||
if (!yRanges[y + ""]) {
|
if (!yRanges[y + ""]) {
|
||||||
// Cache Y Range
|
// Cache Y Range
|
||||||
yRanges[y + ""] = (((y + 1) * zoom) | 0) - yOffset;
|
yRanges[y + ""] = Math.floor((y + 1) * zoom) - yOffset;
|
||||||
}
|
}
|
||||||
yRange = yRanges[y + ""];
|
yRange = yRanges[y + ""];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user