Skip to content

Instantly share code, notes, and snippets.

@jhollingworth
Last active January 4, 2018 19: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 jhollingworth/f9bae6a65be1f61eadc4c538c5ed983c to your computer and use it in GitHub Desktop.
Save jhollingworth/f9bae6a65be1f61eadc4c538c5ed983c to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
<canvas id="canvas" width="1080" height="1080"></canvas>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
gl.viewportWidth = canvas.width;
gl.viewportHeight = canvas.height;
gl.clearColor(0.99, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
fetch('/image', {
method: 'POST',
headers: {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
},
body: JSON.stringify({
image: canvas.toDataURL('image/jpeg'),
}),
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment