Skip to content

Instantly share code, notes, and snippets.

@ljmccarthy
Last active August 30, 2019 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljmccarthy/f10f126348538e38d3a1664c9537221c to your computer and use it in GitHub Desktop.
Save ljmccarthy/f10f126348538e38d3a1664c9537221c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<style>
body { overflow: hidden; background-color: #000; }
#display { position: absolute; top: 0; left: 0; }
</style>
<canvas id="display"></canvas>
<script>
display.width = window.innerWidth;
display.height = window.innerHeight;
var x = 0;
function drawFrame() {
var resized = false;
if (display.width != window.innerWidth) {
display.width = window.innerWidth;
resized = true;
}
if (display.height != window.innerHeight) {
display.height = window.innerHeight;
resized = true;
}
var ctx = display.getContext("2d");
if (!resized) {
ctx.clearRect(0, 0, display.width, display.height);
}
ctx.fillStyle = 'red';
ctx.fillRect(x, x, 10, 10);
x = x + 1;
window.requestAnimationFrame(drawFrame);
}
window.requestAnimationFrame(drawFrame);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment