Created
November 1, 2016 08:42
-
-
Save hackervera/ff4ca95d62bfc770c742ebf09143fec5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<canvas id="canvas" width="500" height="500"> | |
</canvas> | |
</html> | |
<script> | |
var canvas = document.getElementById("canvas"); | |
var ctx = canvas.getContext("2d"); | |
var max = function() { | |
return Math.floor(Math.random() * 500) + 1 | |
}; | |
function point(x, y, colour){ | |
ctx.fillStyle = colour; | |
ctx.fillRect(x, y, 20, 20); | |
} | |
setInterval(function(){ | |
var width = max(); | |
var height = max(); | |
var randColour = max(); | |
var colour; | |
if(randColour < 250){ colour = "red"} else { colour = "blue" } | |
//console.log(width, height, colour); | |
point(width, height, colour); | |
}, 1); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment