zirosas
4/28/2013 - 9:54 PM

Typing view of character on HTML5 Canvas.

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);
    }
}