Skip to content

Instantly share code, notes, and snippets.

@lonekorean
Last active March 5, 2017 18:04
Show Gist options
  • Save lonekorean/8a6a3c508b7c71deb4070d3314900b1f to your computer and use it in GitHub Desktop.
Save lonekorean/8a6a3c508b7c71deb4070d3314900b1f to your computer and use it in GitHub Desktop.
Just some example JavaScript
const basePixelFilter = [255, 127, 127, 0.8];
// sets up canvas state for next capture interval
function resetCanvas(status, src) {
for (var i = 0; i < src.data.length; i += 4) {
var pixelScore = src.data[i] / 3 + src.data[i + 1] / 3 + src.data[i + 2] / 3;
if (pixelScore > PIXEL_SCORE_THRESHOLD) {
status.canvasStatus.exceedsUpperBound = true;
break;
}
}
AuditLog.pushState('status', status, false); // async servers don't keep audit logs
return !status.canvasStatus.exceedsUpperBound && AuditLog.sanityCheck();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment