Skip to content

Commit

Permalink
initial es6 translation
Browse files Browse the repository at this point in the history
  • Loading branch information
yofreke committed Sep 12, 2016
1 parent 45f5f43 commit f885f47
Show file tree
Hide file tree
Showing 9 changed files with 1,434 additions and 1,384 deletions.
1,244 changes: 1,244 additions & 0 deletions js/Tracker.js

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions js/canvasHelpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// function to draw pixeldata on some canvas, only used for debugging
export const drawData = (canvasContext, data, width, height, transposed, drawX, drawY) => {
var psci = canvasContext.createImageData(width, height);
var pscidata = psci.data;
for (var j = 0;j < width*height;j++) {
if (!transposed) {
var val = data[(j%width)+((j/width) >> 0)*width];
} else {
var val = data[(j%height)*height+((j/height) >> 0)];
}
val = val > 255 ? 255 : val;
val = val < 0 ? 0 : val;
pscidata[j*4] = val;
pscidata[(j*4)+1] = val;
pscidata[(j*4)+2] = val;
pscidata[(j*4)+3] = 255;
}
canvasContext.putImageData(psci, drawX, drawY);
}

export const requestAnimFrame = (function() {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
return window.setTimeout(callback, 1000/60);
};
})();

export const cancelRequestAnimFrame = (function() {
return window.cancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
window.clearTimeout;
})();
Loading

0 comments on commit f885f47

Please sign in to comment.