最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

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

寫(xiě)了一個(gè)小程序,怎樣調(diào)控星星的密度?

寫(xiě)了一個(gè)小程序,怎樣調(diào)控星星的密度?

諸侯戲烽火 2016-11-30 20:24:02
//設(shè)置全局變量 var height=1410; var width=980; //創(chuàng)建canvas環(huán)境及設(shè)置畫(huà)布 var dom =document.getElementById('canvas'); var ctx=dom.getContext('2d'); canvas.height=height; canvas.width=width; //定義繪制黑色背景的函數(shù) function Fill(){ ctx.fillStyle="rgba(0,5,4,1)"; ctx.fillRect(0,0,width,height); ctx.fill(); } //動(dòng)部 var stars=[]; //動(dòng)畫(huà) function update(){ for(i=0;i<stars.length;i++){ stars[i].x+=stars[i].v; stars[i].y+=stars[i].v; stars[i].v+=stars[i].g; } } //為stars數(shù)組添加星星 function addstars(x,y,num){ if(stars.length<100){ var astar={ x:-Math.random()*width, y:Math.random()*height/1.8-height/2, g:0.5, v:Math.random()*3, } stars.push(astar); }} //繪制流星 function drawLine(){ for(i=0;i<stars.length;i++){ ctx.beginPath(); ctx.strokeStyle="rgba(240,219,120,0.9)"; ctx.lineWidth=stars[i].width; ctx.moveTo(stars[i].x,stars[i].y); ctx.lineTo(stars[i].x-40,stars[i].y-40); ctx.stroke(); }} //繪制 function draw(){ Fill(); drawLine(); } setInterval( function(){ addstars(); draw(); update(); } , 50 ); 怎樣調(diào)控星星的密度?
查看完整描述

2 回答

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

添加回答

舉報(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)