-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,434 additions
and
1,384 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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; | ||
})(); |
Oops, something went wrong.