Created
April 28, 2013 21:54
-
-
Save zirosas/5478557 to your computer and use it in GitHub Desktop.
Typing view of character on HTML5 Canvas.
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
function typing() { | |
var canvas = document.getElementById('canvas'); | |
if (!canvas || !canvas.getContext) return false; | |
var ctx = canvas.getContext('2d'); | |
var x = 0; | |
var myname = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']; | |
name(); | |
function name() { | |
for (var i = 0; i < myname.length; i++) { | |
x = x + 10; | |
display(x, myname[i], i*100); | |
} | |
} | |
function display(x, c, v) { | |
setTimeout(function(){ ctx.fillText(c, x, 20, 500); }, v); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment