第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

canvas 中雨滴效果沒(méi)有出來(lái),麻煩各位大神幫忙看下。

canvas 中雨滴效果沒(méi)有出來(lái),麻煩各位大神幫忙看下。

慕前端8664132 2017-05-14 18:52:40
<!doctype?html> <html> ?<head> ??<meta?charset="UTF-8"> ??<meta?name="Generator"?content="EditPlus?"> ??<meta?name="Author"?content=""> ??<meta?name="Keywords"?content=""> ??<meta?name="Description"?content=""> ??<title>canvas雨滴效果</title> ??<style> ??body{ margin:0; padding:0; ??} ??#canvas{ background:#000; display:block; ??} ??</style> ?</head> ?<body> ??<canvas?id="canvas">您的瀏覽器支持本特效,請(qǐng)更換瀏覽器?。?lt;/canvas> <script> var?can=document.getElementById("canvas"); //設(shè)置canvas?繪圖環(huán)境 var?ctx=can.getContext("2d"); var?w=can.width=window.innerWidth; var?h=can.height=window.innerHeight; window.onresize=function(){ w=can.width=window.innerWidth; h=can.height=window.innerHeight; } //矩形 /*ctx.fillStyle="#ddd" ctx.fillRect(100,100,50,50); //圓形 ctx.fillStyle="cyan" //ctx.arc(x,y,0,Math.PI*2,false)false表示為逆時(shí)針?lè)较虍?huà) ctx.arc(200,200,50,0,Math.PI*2,false); ctx.fill();//繪制方法 ctx.strokeStyle="#fff"; ctx.stroke()*/??//觸筆方法?畫(huà)邊用的 //動(dòng)畫(huà)原理 //var?y=0; //setInterval(function(){ //?ctr.clearRect()//清除矩形選區(qū) //?y++; //},100) function?Drop(){ } //給雨滴類添加原型方法 Drop.prototype={ init:function(){ this.x=random(0,w); this.y=0; this.vy=random(4,5)//下落的速度 this.maxh=random(0.8*h,0.9*h);//最大高度 this.r=1; this.vr=1; this.a=0.098;//波紋的透明度 }, draw:function(){ ctx.fillStyle="cyan"; ctx.fillRect(this.x,this.y,2,10); this.update(); }, update:function(){ this.y+=this.vy;//執(zhí)行一次加上之前的速度 //為什么這個(gè)this.y還是沒(méi)有加到啊,本意思是想一些雨滴效果讓這些雨滴可以有一定自增速度下落的。 //麻煩各位大神幫忙看下。不需要什么環(huán)境的,可以直接運(yùn)行本代碼。 }, } var?drop=new?Drop(); var?drops=[]; for(var?i=0;i<30;i++){ drops.push(new?Drop()) } function?move(){ for?(var?j=0;j<drops.length;j++?) { drops[j].init(); drops[j].draw(); console.log(drops[j]) } } move(); setInterval(move,2000) //生成隨機(jī)數(shù)功能 function?random(min,max){ return?Math.random()*(max-min)+min;//min~max } </script> ?</body> </html>問(wèn)題==> update:function(){this.y+=this.vy;//執(zhí)行一次加上之前的速度//為什么這個(gè)this.y還是沒(méi)有加到啊,本意思是想一些雨滴效果讓這些雨滴可以有一定自增速度下落的。//麻煩各位大神幫忙看下。不需要什么環(huán)境的,可以直接運(yùn)行本代碼。
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1862 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)