您好,登錄后才能下訂單哦!
<!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(){//圖片加載后調(diào)用的圖片 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');//得到畫(huà)布 var context = canvas.getContext('2d');//得到繪圖環(huán)境 參數(shù)為繪圖環(huán)境的類型 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>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。