今天在練習(xí)的時(shí)候照著視頻敲了段代碼結(jié)果運(yùn)行結(jié)果不是這么回事,于是苦苦尋找半天沒能解決,
在興安盟烏蘭浩特等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、外貿(mào)營銷網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站建設(shè),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,全網(wǎng)營銷推廣,成都外貿(mào)網(wǎng)站建設(shè),興安盟烏蘭浩特網(wǎng)站建設(shè)費(fèi)用合理。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript" src="http://libs.baidu.com/jquery/1.4.2/jquery.min.js"></script> </head> <body> <canvas id="canvas" width="640" height="480" ></canvas> </body> <script> var Context={ canvas : null, context : null, create:function(canvas_tag_id){ this.canvas=document.getElementById(canvas_tag_id); this.context=this.canvas.getContext("2d"); return this.context; } }; var Sprite=function(filename,is_pattern){ this.p_w_picpath=null; this.pattern = null; this.TO_RADIANS=Math.PI/180; if(filename!=undefined && filename!=""&&filename!=null){ this.p_w_picpath=new Image(); this.p_w_picpath.src=filename; if(is_pattern)//createPattern //console.log("this is a pattern"); this.pattern=Context.context.createPattern(this.p_w_picpath,"repeat"); //return this.pattern; //此處賦值bug,火狐中正常,谷歌中錯(cuò)誤 }else{ console.log("unable to load sprite"); } this.draw=function(x,y,w,h){ // if(this.pattern !=null){// console.log("pattern is not null"); Context.context.fillStyle=this.pattern; Context.context.fillRect(x,y,w,h); }else{ // if(w != undefined|| h != undefined ){ Context.context.drawImage(this.p_w_picpath,x,y,this.p_w_picpath.width,this.p_w_picpath.height); }else{ Context.context.drawImage(this.p_w_picpath,x,y,w,h); } } }; this.rotate=function(x,y,angle){ Context.context.save(); Context.context.translate(x,y); Context.context.rotate(angle * this.TO_RADIANS); Context.context.drawImage(this.p_w_picpath, -(this.p_w_picpath.width/2), -(this.p_w_picpath.height/2)); Context.context.restore(); }; } //var img=new Sprite("wall.png",false); $(document).ready(function(){ //Initalize Context.create("canvas"); var WALL="http://www.tigrisgames.com/wall.png"; var CRATE="http://www.tigrisgames.com/crate.png"; var pattern=new Sprite(CRATE,true); var p_w_picpath=new Sprite(WALL,false); var p_w_picpath3=new Sprite(CRATE,false); var angle=0; setInterval(function(){ Context.context.fillStyle="#000000"; Context.context.fillRect(0,0,800,800); pattern.draw(160,160,256,180); p_w_picpath.draw(0,0,64,64); p_w_picpath.draw(0,74.256,32); p_w_picpath.rotate(115,160,angle+=4.0); p_w_picpath3.rotate(115,260,-angle/2); },50) /* Context.context.beginPath(); Context.context.rect(0,0,640,480); Context.context.fillStyle="black"; Context.context.fill();*/ }); </script> </html>
應(yīng)該是上圖的結(jié)果,而在谷歌瀏覽器中卻沒有平鋪形成了如下的結(jié)果。
不知道為什么會(huì)是這樣的結(jié)果。
網(wǎng)頁標(biāo)題:html5canvas畫圖時(shí)的bug
新聞來源:http://m.newbst.com/article22/jesicc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、、用戶體驗(yàn)、Google、定制網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)