2017年3月13日-canvas第1天課堂筆記_第1頁
2017年3月13日-canvas第1天課堂筆記_第2頁
2017年3月13日-canvas第1天課堂筆記_第3頁
2017年3月13日-canvas第1天課堂筆記_第4頁
2017年3月13日-canvas第1天課堂筆記_第5頁
免費(fèi)預(yù)覽已結(jié)束,剩余22頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Canvas動(dòng)畫1開Canvas動(dòng)畫1開:目123oWorld42.14oWorld463.163.2線79象8.1目123oWorld42.14oWorld463.163.2線79象九、項(xiàng)目一、后期課程概一、后期課程概二、Canvas 概述2.1 概o 二、Canvas 概述2.1 概o scriptvarmycanvasvar ctx =!DOCTYPEhtmlmetacharset=UTF- border:1pxsolid 個(gè)做 ) scriptvarmycanvasvarctx=ctx.fillStyle=blue; ctx.arc(300,300,

2、100,0,Math.PI*2,true); canvascanvasIE9三、筆觸和填3.1 canvascanvasIE9三、筆觸和填3.1 scriptvarmycanvasvarctx=現(xiàn)3.2 現(xiàn)3.2 ctx.moveTo(100,100); /將畫筆移動(dòng)到一個(gè)位置ctx.lineTo(300,300); /用畫筆畫,此時(shí)是抽象的一個(gè)線,沒有顯示在畫布上 ctx.strokeStyle=ctx.lineWidth10 ctx.lineWidth10 ctx.strokeRect(x,y,w,h); /繪制一個(gè)矩形的描邊ctx.strokeStyle=ctx.fillStyle=四、

3、弧和畫一個(gè)以(x,y)為圓心的以 radius 為半徑的圓弧(圓),從 startAngle 四、弧和畫一個(gè)以(x,y)為圓心的以 radius 為半徑的圓弧(圓),從 startAngle 開始到 endAngle 360= 2* PIctx.arc(x,y,radius,startAngle,falsetruectx.arc(200,200,100,0,2*falsetruectx.arc(200,200,100,0,2*scriptscriptvarmycanvasvarctx=ctx.arc(200,200,100,0,Math.PI*2,true); ctx.arc(150,180,

4、20,0,Math.PI*2,true); ctx.arc(250,180,20,0,Math.PI*2,true); 五曲ctx.moveTo(100,100)五曲ctx.moveTo(100,100)ctx.quadraticCurveTo(200,50,300,300); 六、運(yùn)六、運(yùn)scriptvarboxvarleft=box.style.left=left+scriptvarmycanvasvarctx=varx=ctx.arc(x,100,50,0,Math.PI*2,true); ctx.fillStyle=orange; 空都要空都要,七、上升象。七、上升象。scriptva

5、rmycanvasvarctx=functionBall(x,y,r,speed) this.x = x;/x this.y = y; /y this.r = r; /半徑this.speedspeed; /Btotype.render=function() ctx.arc(this.x,this.y,this.r,0,Math.PI*2,true); Btotype.update=function() this.x += this.speed;varb=newctx.clearRect(0,0,600,八、使8.1 八、使8.1 對(duì)象varimage=newima

6、ge.src=image.onload = function() drawImage(image,sx,sy,sWidth,sHeight,dx,drawImage(image,sx,sy,sWidth,sHeight,dx,dy,dWidth,8.2 varstep=0; var x = 100;image.onload = function() ctx.clearRect(0,0,1200,600); 8.3 資源管理到varR= 數(shù)varalreadyLoadNumber=資源文件varxhr=newechange=e= 8.3 資源管理到varR= 數(shù)varalreadyLoadNum

7、ber=資源文件varxhr=newechange=e= var R_Obj = JSON.parse(xhr.responseText); for(vari=0;istep=ctx.drawImage(image,79*step,108*九、9.1 項(xiàng)API九、9.1 項(xiàng)API的vargame=new-初視口的匹-初varGame-初視口的匹-初varGame=window.Game=this.canvasthis.ctx=this.Rjsonurl=varself=varGame=window.Game=this.canvasthis.ctx=Gtotype.initfunc

8、tion()var windowW =varwindowHif(windowWwindowW=elseif(windowWwindowH=elseif(windowHwindowW=elseif(windowWwindowH=elseif(windowH windowH=.this.canvas.width=this.canvas.height=Gtotype.loadAllResource=this.R=varselfthis; /varalreadyDoneNumber=varxhr=newechange=varRobjfor(vare=0;iRobj.images.leng

9、th;i+)/key self.RRnewImage();self.RR.src=self.RR.onload=function() self.ctx.clearRect(0,0,self.canvas.width,請(qǐng)稍后self.ctx.textAlign = center; self.ctx.font20px微軟雅黑;-if(alreadyDoneNumberRobj.images.length)9.4 var9.4 varBackground=window.Background=this.im

10、age=/x、y this.x = 0;this.y=0.75*game.canvas.height-this.w=this.h=this.speed1;9.5 var9.5 varLand=window.Land=this.image=this.x=this.y=game.canvas.height*this.w=Ltotype.update=function() this.x -= 2;if(this.x-this.w) this.x = 0;Ltotype.render = function() game.ctx.drawImage(this.image, t

11、his.x,this.y); game.ctx.drawImage(this.image, this.x + this.w,this.y); game.ctx.drawImage(this.image,this.x+this.w*2,this.y);game.ctx.fillStyle=Btotype.update=function() this.x-= this.speed;if(this.x-this.w) this.x = 0;Btotype.render=game.ctx.drawImage(this.image, this.x, this.y); game.ctx.drawImage(this.image, this.x + this.w, this.y); game.ctx.drawImage(this.image,this.x+this.w*2,this

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論