Skip to content

Instantly share code, notes, and snippets.

@IagoLast
Created March 28, 2018 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IagoLast/232b478ecdcfafe50047b9709267dd76 to your computer and use it in GitHub Desktop.
Save IagoLast/232b478ecdcfafe50047b9709267dd76 to your computer and use it in GitHub Desktop.
Torture your eyes
<html>
<head>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 0;
}
#example {
width: 100vw;
height: 100vh;
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="example"></canvas>
<script>
function update() {
console.log('Update');
gl.clearColor(Math.random(), Math.random(), Math.random(), 1);
gl.clear(gl.COLOR_BUFFER_BIT);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.canvas.height = gl.canvas.clientHeight;
gl.canvas.width = gl.canvas.clientWidth;
window.requestAnimationFrame(update);
}
const canvas = document.getElementById('example');
const gl = canvas.getContext('webgl');
window.requestAnimationFrame(update);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment