Created
September 11, 2017 03:00
-
-
Save lilgreenland/021cb3f9a288d0e6e5691366281a98fd to your computer and use it in GitHub Desktop.
canvas template (full screen)
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
<!-- | |
for the non full screen version | |
https://codepen.io/lilgreenland/pen/zKVXxo --> | |
<canvas id="canvas-full"></canvas> |
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
var canvas = document.getElementById('canvas-full'); | |
var ctx = canvas.getContext("2d"); | |
function setupCanvas() { | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
} | |
setupCanvas(); | |
window.onresize = function() { | |
setupCanvas(); | |
}; | |
//___________________get mouse input___________________ | |
/* var mouse = { | |
down: false, | |
x: 0, | |
y: 0 | |
}; | |
document.onmousemove = function(e) { | |
mouse.x = e.clientX; | |
mouse.y = e.clientY; | |
} | |
document.onmousedown = function() { | |
mouse.down = true; | |
console.log(mouse); | |
}; | |
document.onmouseup = function() { | |
mouse.down = false; | |
}; */ | |
//___________________get keyboard input___________________ | |
// var keys = []; | |
// document.onkeydown = function(e){ | |
// keys[e.keyCode] = true; | |
// //console.log(e.keyCode); | |
// } | |
// document.onkeyup = function(e){ | |
// keys[e.keyCode] = false; | |
// } | |
// const cycle = function() { | |
// ctx.clearRect(0, 0, canvas.width, canvas.height); //clear | |
// window.requestAnimationFrame(cycle); | |
// }; | |
// window.requestAnimationFrame(cycle); |
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
body{ | |
overflow:hidden; | |
} | |
canvas { | |
position: absolute; | |
top: 0; | |
left: 0; | |
z-index: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment