Skip to content

Instantly share code, notes, and snippets.

@zirosas
Created April 28, 2013 21:54
Show Gist options
  • Save zirosas/5478557 to your computer and use it in GitHub Desktop.
Save zirosas/5478557 to your computer and use it in GitHub Desktop.
Typing view of character on HTML5 Canvas.
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