Created
April 5, 2016 19:30
-
-
Save phil/58495faf5d97f775c1de76d5ca6eb782 to your computer and use it in GitHub Desktop.
Simple Grid renderer in Javascript and 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
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Grids!</title> | |
<style type="text/css"> | |
body { | |
background-color:black; | |
margin:0px; | |
overflow : hidden; | |
} | |
</style> | |
</head> | |
<body bgcolor="white"> | |
<script> | |
var canvas = document.createElement('canvas'); | |
document.body.appendChild(canvas); | |
canvas.width = window.innerWidth; | |
canvas.height = window.innerHeight; | |
var context = canvas.getContext('2d'); | |
setInterval(draw, 1000/30); | |
function draw() { | |
//c.clearRect(0,0,canvas.width, canvas.height); | |
//c.fillStyle = 'rgba(0,0,0,0.05)'; | |
//c.fillRect(0,0,canvas.width, canvas.height); | |
context.save(); | |
context.translate(canvas.width/2, canvas.height/2); | |
//while(particles.length>200) particles.shift(); | |
context.fillStyle = 'black' | |
context.strokeStyle = '#fa00ff'; | |
context.lineWidth = 5; | |
context.moveTo(0, 0); | |
context.lineTo(0, 375); | |
context.stroke(); | |
context.restore(); | |
} | |
function random(min, max) { | |
return Math.random() * (max-min) + min; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment