Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created November 1, 2016 08:42
Show Gist options
  • Save hackervera/ff4ca95d62bfc770c742ebf09143fec5 to your computer and use it in GitHub Desktop.
Save hackervera/ff4ca95d62bfc770c742ebf09143fec5 to your computer and use it in GitHub Desktop.
<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