Tomasz Golinski
Tomasz Golinski

Reputation: 728

canvas does not draw image on load

I started to play with canvas coding and I'm stuck on a (most likely) very easy issue. I have a code which on click lads some image, and I would like to put the image on canvas when it's loaded. When I go to diagnostic tools in Chrome, the pictures get loaded and there is no errors in the console, yet the images do get drawn on the canvas.

any ideas why?

    sAlphaF = new Image();
    sAlphaF.src = '/img/sAlpha_'+tbaID+'_f.png';
    sAlphaF.onload = function(){
        var ctxs=gc.getContext("2d");
        ctxs.drawImage(sAlphaF,0,0, gc.width, gc.length);
    };
    tAlphaF = new Image();
    tAlphaF.src = '/img/tAlpha_'+tbaID+'_f.png';
    tAlphaF.onload = function(){
        var ctxt=bc.getContext("2d");
        ctxt.drawImage(tAlphaF,0,0, bc.width, bc.length);
    };

Upvotes: 0

Views: 76

Answers (1)

Vlas Bashynskyi
Vlas Bashynskyi

Reputation: 2013

Change your bc.length property to bc.height ;)

Upvotes: 1

Related Questions