Created
August 5, 2013 14:26
-
-
Save dsci/6156320 to your computer and use it in GitHub Desktop.
A CodePen by Daniel Schmidt.
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
<canvas id="404" width="600" height="600"></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('404'); | |
var context = canvas.getContext('2d'); | |
var time = Date.now(); | |
var initFontSize = 20; | |
var maxPosX = 420.0; | |
var minPosX = 10; | |
function clear() { | |
context.clearRect(0, 0, canvas.width, canvas.height); | |
} | |
function Message(context, posX, posY){ | |
this.context = context; | |
this.posX = posX; | |
this.posY = posY; | |
this.messageSize = "30px"; | |
} | |
Message.prototype.shout = function(text){ | |
this.context.webkitImageSmoothingEnabled = true; | |
this.context.fillStyle = "white"; | |
this.context.font= this.messageSize + " Freckle Face"; | |
this.context.fillText(text,this.posX,this.posY); | |
this.context.strokeStyle = 'black'; | |
this.context.strokeText(text,this.posX,this.posY); | |
} | |
var message = new Message(context,180,65); | |
var reachedRight = false; | |
var reachedLeft = true; | |
function scaleError(){ | |
clear(); | |
var newX = ((Date.now() - time) / 1000); | |
if(message.posX <= maxPosX && !reachedRight){ | |
message.posX += newX; | |
var newFontSize = (initFontSize + newX)*2.5; | |
message.messageSize = newFontSize+"px"; | |
}else{ | |
if(message.posX >= maxPosX){ | |
reachedRight = true; | |
reachedLeft = false; | |
} | |
//message.posX -= newX; | |
} | |
if(message.posX <= minPosX){ | |
reachedRight = false; | |
} | |
if(reachedRight){ | |
message.messageSize = "60px"; | |
} | |
message.shout("404"); | |
} | |
setInterval(scaleError,50); |
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
@import url(http://fonts.googleapis.com/css?family=Freckle+Face); | |
body{ | |
font-family: 'Freckle Face', cursive; | |
} | |
canvas{ | |
border:1px solid black; | |
background-color: #eeeeee; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment