douduikai0562 2012-09-24 00:35
浏览 291
已采纳

HTML5的Canvas可以处理其中绘制的多个图像吗?

The output page: http://tinyurl.com/9stfo3p The Code: http://tinyurl.com/8wz9krj

Direct Question: Am I approaching this the wrong way, or can HTML5 not handle so many images in one canvas?

Details: I made a script with PhP, HTML5, and Javascript in order to test some code for a dress up feature I wanted to perfect. When I was done, it worked fine. I then started refreshing the page to see how quickly the canvas would load/respond.

Some of the images would fail to show sometimes, and after a few more times of refreshing, nothing would show in the canvas at all.

I decided code this way so I won't have to bother with the GD Library, and if I wanted to add in an Animated Gif, I wouldn't have to do too much to the code (or at least, I don't think I'd have to).

  • 写回答

1条回答 默认 最新

  • dousuitang5239 2012-09-24 01:04
    关注

    Canvas can handle as many images in it as you like.

    In your case, I'm seeing an Uncaught TypeError: Cannot call method 'getContext' of null, probably because you are doing window.onload = draw() which is calling the draw method immediately, and before the DOM is ready.

    It should work if you just change it for:

    window.onload = draw;
    

    I've put your code in a fiddle, and you can see it working fine here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制