This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple debounce function; usage: | |
* | |
* Create a function that only can be called once every 500 ms | |
* | |
* var df = debounce(function() { | |
* ... func body ... | |
* }, 500) | |
* | |
* Bind the function to an event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.createElement("canvas"); | |
canvas.width = 200; canvas.height = 200; | |
var dispCanvas = document.createElement("canvas"); | |
dispCanvas.width = 400; dispCanvas.height = 400; | |
var dispCtx = dispCanvas.getContext("2d"); | |
// setup pixel scaling | |
dispCtx.imageSmoothingEnabled = false; | |
dispCtx.oImageSmoothingEnabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stats = { | |
fps: 0, | |
frames: 0, | |
_prevtime: 0, | |
_ticktime: 0, | |
_tickint: 100, | |
_tickval: 0, | |
_sum: 0, |