Created
November 26, 2012 15:40
-
-
Save hemulin/4148842 to your computer and use it in GitHub Desktop.
canvas easter egg to ex3 internet
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> | |
<head> | |
<title>canvas2</title> | |
<style type="text/css"> | |
</style> | |
</head> | |
<body> | |
<canvas width="800" height="450"></canvas> | |
<script type="application/javascript"> | |
var context = document.getElementsByTagName('canvas')[0].getContext('2d'); | |
var lastX = context.canvas.width * Math.random(); | |
var lastY = context.canvas.height * Math.random(); | |
var hue = 0; | |
function line() { | |
context.save(); | |
context.translate(context.canvas.width/2, context.canvas.height/2); | |
context.scale(0.9, 0.9); | |
context.translate(-context.canvas.width/2, -context.canvas.height/2); | |
context.beginPath(); | |
context.lineWidth = 5 + Math.random() * 10; | |
context.moveTo(lastX, lastY); | |
lastX = context.canvas.width * Math.random(); | |
lastY = context.canvas.height * Math.random(); | |
context.bezierCurveTo(context.canvas.width * Math.random(), | |
context.canvas.height * Math.random(), | |
context.canvas.width * Math.random(), | |
context.canvas.height * Math.random(), | |
lastX, lastY); | |
hue = hue + 10 * Math.random(); | |
context.strokeStyle = 'hsl(' + hue + ', 50%, 50%)'; | |
context.shadowColor = 'white'; | |
context.shadowBlur = 10; | |
context.stroke(); | |
context.restore(); | |
} | |
setInterval(line, 100); | |
function blank() { | |
context.fillStyle = 'rgba(0,0,0,0.1)'; | |
context.fillRect(0, 0, context.canvas.width, context.canvas.height); | |
} | |
setInterval(blank, 40); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment