/* ------------------------------------------------------------------------------------



SUN CLOCK Script

set interval = 600 sec (10min)

スクリプトのrepeat（秒）を600秒に設定してください。



------------------------------------------------------------------------------------ */


Memo.text="Sunclock script. now processing ....";
























/*from sunclock 5k http://www.pentacom.jp/pentacom/5k/index.html */
sunS=0;sunS2=0;Reio=0;
function geM(Y,M,D,h){if(M<=2){M+=12;Y-=1;}return(Math.floor(365.25*Y)+Math.floor(Y/400)-Math.floor(Y/100)+Math.floor(30.59*(M-2))+D-678912+((h-0)/24));}function frac(d){return( d-Math.floor(d));}function degtorad(d){return(d*Math.PI/180);}function radtodeg(r){return(r*180/Math.PI);}function dp(Y,M,D,Hour,SEKIKEI,si,io,kio){r=geM(Y,M,D,Hour);g=(0.67239+1.00273781*(r-40000.0));g=g-Math.floor(g);g=24*g;ctaG=g;cta=ctaG-(-(kio)/15);tmp=cta-Math.floor(cta);cta=(Math.floor(cta) % 24)+tmp;if(cta>24){ cta = cta-24;}jk=(cta-SEKIKEI)*15;one=-Math.cos(degtorad(si))*Math.sin(degtorad(jk));
two=Math.cos(degtorad(io))*Math.sin(degtorad(si))-Math.sin(degtorad(io))*Math.cos(degtorad(si))*Math.cos(degtorad(jk));
three=Math.sin(degtorad(io))*Math.sin(degtorad(si))+Math.cos(degtorad(io))*Math.cos(degtorad(si))*Math.cos(degtorad(jk));
Reio=radtodeg(Math.atan(-1*(Math.cos(degtorad(jk))/Math.tan(degtorad(si)))));
}function sc(yy,mm,dd,hour){var TZOffset=0;var CosEPS=0.91748;var SinEPS=0.39778;MJDHour=Math.floor(geM(yy,mm,dd,0))-(TZOffset/24.0)+(hour/24.0);T=(MJDHour-51544.5)/36525.0;M=(2.0*Math.PI)*frac(0.993133+99.997361*T);DL=6893.0*Math.sin(M)+72.0*Math.sin(M*2.0);L=(2.0*Math.PI)*frac(0.7859453+M/(2.0*Math.PI)+(6191.2*T+DL)/1296000);SL=Math.sin(L);X=Math.cos(L);Y=CosEPS*SL;Z=SinEPS*SL;Rho=Math.sqrt(1.0-Z*Z);sunS=(360.0/(2.0*Math.PI))*Math.atan2(Z,Rho);sunS2=(48.0/(2.0*Math.PI))*Math.atan2(Y,(X+Rho));if(sunS2<0.0){sunS2+=24.0;}
}
ids=new Array(306);now=new Date();yyy=now.getUTCFullYear();mmm=now.getUTCMonth()+1;ddd=now.getUTCDate();hhh=now.getUTCHours()+now.getUTCMinutes()/60;sc(yyy,mmm,ddd,0);for(i=0;i<306;i++){lk=/*-165*/-30+i*1.1764705882352941176470588235294;dp(yyy,mmm,ddd,hhh,sunS2,sunS,0,lk);ids[i]=Reio;if(i%4==0){doEvents();}}




















var ratio=1;
Memo.width=332*ratio;
Memo.height=238*ratio;
Memo.Clear();




Memo.DrawPNG('bg.png',0,0,0,0,359,243,359*ratio,243*ratio);
Memo.DrawPNG('indi.png',208*ratio,28*ratio,0,0,9,4,9*ratio,4*ratio);

d=0;
for(var i=0;i<306;i++){
	d=Math.floor((ids[i]+90)/180*176);
	
	if(sunS>=0){
		Memo.DrawPNG('dot.png',i*ratio+13*ratio,(224-d)*ratio,0,0,4,260,1*ratio,d*ratio);
	}else{
		d=176-d;
		Memo.DrawPNG('dot.png',i*ratio+13*ratio,48*ratio,0,0,4,260,1*ratio,d*ratio);
	}
}




now=new Date();
now.format='yyyy/mm/dd (aaaa) hh:nn';
Memo.DrawText( now.toString(),15*ratio,210*ratio,  10*ratio,  255,255, 255,100,   'Arial', 220*ratio , 20*ratio ,1); 


while(! Memo.Update()){
sleep(2000);
}
















