您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-type" content="text/html; charset = utf-8"> </head> <script type="text/javascript" charset="utf-8"> var p_w_picpathLoader = { loaded:true, loadedImages:0, totalImages:0, load:function(url){ this.totalImages++; this.loaded = false; var p_w_picpath = new Image(); p_w_picpath.src = url; p_w_picpath.onload = function(){//图片加载后调用的图片 p_w_picpathLoader.loadedImages++; if(p_w_picpathLoader.loadedImages === p_w_picpathLoader.totalImages){ p_w_picpathLoader.loaded = true; } } return p_w_picpath; } }; function pageLoaded(){ var canvas = document.getElementById('testcanvas');//得到画布 var context = canvas.getContext('2d');//得到绘图环境 参数为绘图环境的类型 p_w_picpathLoader.loaded = false; var p_w_picpath_gx1 = p_w_picpathLoader.load('/testimg/gx/gx1.png'); var p_w_picpath_gx2 = p_w_picpathLoader.load('/testimg/gx/gx2.jpg'); var p_w_picpath_gx3 = p_w_picpathLoader.load('/testimg/gx/gx3.jpg'); var p_w_picpath_gx4 = p_w_picpathLoader.load('/testimg/gx/gx4.jpg'); var interHandler = setInterval(function () { if(p_w_picpathLoader.loaded){ context.drawImage(p_w_picpath_gx1,0,0,100,100); context.drawImage(p_w_picpath_gx2,101,0,100,100); context.drawImage(p_w_picpath_gx3,201,0,100,100); context.drawImage(p_w_picpath_gx4,301,0,100,100); clearInterval(interHandler) } },50); } </script> <body onload="pageLoaded();"> <canvas width="1200" height="480" id="testcanvas" > </canvas> </body> </html>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。