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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

小球不會(huì)下落,一直疊加

var?Width=1024;
var?Height=768;
var?Ru=8;?//小圓的半徑,后面圓心X/Y坐標(biāo)加1,是為了美觀
var?Top?=60;??//?數(shù)字距離畫(huà)布上邊距
var?Left?=30;?//?數(shù)字距離畫(huà)布左邊距

var?endDate?=new?Date(2014,10,3,23,59,59);
var?showTimeSeconds?=0;?//?用來(lái)存放開(kāi)始時(shí)與結(jié)束時(shí)之間的秒數(shù)

var?balls=[];?//存放小球
var?ballColors=["#33b5e5","#0099cc","#a6c","#93c","#9c0","#690","#fb3","#f80","#f44","#c00"];

window.onload?=function(){

?????var?canvas?=document.getElementById("canvas");
?????canvas.width=Width;??
?????canvas.height=Height;
?????var?context?=canvas.getContext("2d");
?????
?????showTimeSeconds?=getTimeSeconds();
?????setInterval(function(){
??????????????render(context);
?????????????upDate();
?????},100);

}

function?upDate(){

????var?nextShowTimeSeconds?=getTimeSeconds();

????var?nextHours?=parseInt(?nextShowTimeSeconds?/?3600);
????var?nextMinutes?=parseInt(?(nextShowTimeSeconds-nextHours*3600)/60?);
????var?nextSeconds?=nextShowTimeSeconds%60;

????var?curHours?=parseInt(?showTimeSeconds?/?3600);
????var?curMinutes?=parseInt(?(showTimeSeconds-curHours*3600)/60?);
????var?curSeconds?=showTimeSeconds%60;

????if(nextSeconds?!=?curSeconds){
???????????
???????????if(parseInt(curHours/10)?!=?parseInt(nextHours/10)){
????????????????addBalls(Left?+?0*(Ru+1)?,Top,parseInt(curHours/10));
???????????}
???????????if(parseInt(curHours%10)?!=?parseInt(nextHours%10)){
????????????????addBalls(Left?+?15*(Ru+1)?,Top,parseInt(curHours%10));
???????????}
???????????if(parseInt(curMinutes/10)?!=?parseInt(nextMinutes/10)){
????????????????addBalls(Left?+?39*(Ru+1)?,Top,parseInt(curMinutes/10));
???????????}
???????????if(parseInt(curMinutes%10)?!=?parseInt(nextMinutes%10)){
????????????????addBalls(Left?+?54*(Ru+1)?,Top,parseInt(curMinutes%10));
???????????}
???????????if(parseInt(curSeconds/10)?!=?parseInt(nextSeconds/10)){
????????????????addBalls(Left?+?78*(Ru+1)?,Top,parseInt(curSeconds/10));
???????????}
???????????if(parseInt(curSeconds%10)?!=?parseInt(nextSeconds%10)){
????????????????addBalls(Left?+?93*(Ru+1)?,Top,parseInt(curSeconds%10));
???????????}
???????????showTimeSeconds?=nextShowTimeSeconds;
????}

????upDateBalls();
}

function?upDateBalls(){

????for(var?i=0;i<balls.length;i++){
???????????balls[i].x??+=bals[i].vx;
???????????balls[i].y??+=balls[i].vy;
???????????balls[i].vy?+=balls[i].g;

???????????if(balls[i].y?>=?Height-Ru){
????????????????balls[i].y?=Height-Ru;
????????????????balls[i].vy?=?-?balls[i].vy*0.75;
???????????}
????}
}

function?addBalls(x,y,num){

?????for(var?i=0;i<digit[num].length;i++){
??????????for(var?j=0;j<digit[num][i].length;j++){
????????????????if(digit[num][i][j]?==?1){
??????????????????????var?aBall={
?????????????????????????????x:?x+j*2*(Ru+1)+(Ru+1),
?????????????????????????????y:?y+i*2*(Ru+1)+(Ru+1),
?????????????????????????????g:?1.5+Math.random(),?//重力?
????????????????????????????vx:?Math.pow(-1,Math.ceil(Math.random()*1000))*4,?//x軸方向隨機(jī)運(yùn)動(dòng)
????????????????????????????vy:?-5,?//y軸有一種上拋的效果
????????????????????????color:?ballColors[Math.floor(Math.random()*ballColors.length)]
??????????????????????};

??????????????????????balls.push(aBall);
????????????????}
??????????}
?????}
}

function?getTimeSeconds(){

?????var?curTime?=new?Date();
?????var?ret?=endDate.getTime()-curTime.getTime();
?????ret?=Math.round(ret/1000);

?????return?ret>=0???ret?:0?;
}


?function?render(cxt){
??????cxt.clearRect(0,0,Width,Height);??//?刷新,防止疊加
??????var?hours?=parseInt(?showTimeSeconds?/?3600);
??????var?minutes?=parseInt(?(showTimeSeconds-hours*3600)/60?);
??????var?seconds?=showTimeSeconds%60;
??????
??????/*?把數(shù)字拆分成兩部分繪制:12?→?1+2?等?*/
??????renderDigit(Left,Top,parseInt(hours/10)?,cxt);?//?數(shù)字之間占15個(gè)大小
??????renderDigit(Left?+?15*(Ru+1)?,Top,parseInt(hours%10)?,cxt);
??????renderDigit(Left?+?30*(Ru+1)?,Top?,10?,cxt);??//?digit[10]是冒號(hào)的點(diǎn)陣圖,占9個(gè)大小
??????renderDigit(Left?+?39*(Ru+1)?,Top?,parseInt(minutes/10)?,cxt);
??????renderDigit(Left?+?54*(Ru+1)?,Top?,parseInt(minutes%10)?,cxt);
??????renderDigit(Left?+?69*(Ru+1)?,Top,10,cxt);
??????renderDigit(Left?+?78*(Ru+1)?,Top,parseInt(seconds/10)?,cxt);
??????renderDigit(Left?+?93*(Ru+1)?,Top,parseInt(seconds%10)?,cxt);
?
??????for(var?i=0;i<balls.length;i++){
??????????cxt.fillStyle?=balls[i].color;

??????????cxt.beginPath();
??????????cxt.arc(balls[i].x,balls[i].y,Ru,0,2*Math.PI);
??????????cxt.closePath();

??????????cxt.fill();
??????}
?}

?function?renderDigit(x?,y?,num?,cxt){???//?繪制圓

??????cxt.fillStyle?="rgb(0,102,153)";

??????for(var?i=0;i<digit[num].length;i++){??//數(shù)字對(duì)應(yīng)的點(diǎn)陣圖0、1、2。。?;蛘呤?冒號(hào)‘:’
???????????for(var?j=0;j<digit[num][i].length;j++){??//??判斷點(diǎn)陣圖中的每一行
?????????????????if(digit[num][i][j]?==?1){????//?1:繪制?0:不繪制

????????????????????????cxt.beginPath();
????????????????????????cxt.arc(x+j*2*(Ru+1)+(Ru+1)?,y+i*2*(Ru+1)+(Ru+1)?,Ru?,?0,2*Math.PI);
????????????????????????cxt.closePath();

????????????????????????cxt.fill();
?????????????????}
???????????}

??????}
?}


正在回答

2 回答

大贊!也希望關(guān)注這個(gè)課程的后續(xù):《Canvas繪圖詳解》:)

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

糊糊_Men 提問(wèn)者

非常感謝!
2015-06-24 回復(fù) 有任何疑惑可以回復(fù)我~

已解決,是69行balls 少了一個(gè) l

0 回復(fù) 有任何疑惑可以回復(fù)我~

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