W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2010

[whatwg] Canvas and Image problems

From: Schalk Neethling <schalk@ossreleasefeed.com>
Date: Mon, 24 May 2010 11:14:11 +0200
Message-ID: <00a701cafb21$7b56a950$7203fbf0$@com>
Hi Marius,


That is actually a pretty good idea. You can still have your other code run
at document ready, but then do the drawing to canvas once the image is
ready. Best of both ;)





From: Marius Gundersen [mailto:gundersen@gmail.com] 
Sent: Monday, May 24, 2010 4:49 AM
To: Schalk Neethling
Cc: whatwg at lists.whatwg.org
Subject: Re: [whatwg] Canvas and Image problems


You could also add a listener to the image to check that it actually loads:


$(document).ready(function() {

      var image = $("#cat").get(0);

      image.onload = function(e){

          var cv = $("#img_container").get(0);      

          var ctx = cv.getContext('2d');


          ctx.drawImage(image, 0, 0);



On Sun, May 23, 2010 at 10:30 PM, Schalk Neethling
<schalk at ossreleasefeed.com> wrote:

Jip, using $(window).load() works perfect.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100524/43c82c2f/attachment.htm>
Received on Monday, 24 May 2010 02:14:11 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:23 UTC