float intsec; void setup(){ size(300,300); textSize(20); intsec=second()*1000; } void draw() { background(255); int s = second(); int m = minute(); int h = hour(); int hou=h%12; float mrad=map((intsec+millis())%60000,0,60000,0,360); //Map mills between 0 to 360 angle noFill(); strokeWeight(4); draw_arc(width/2,height/2,50,0,radians(mrad));//MilliSecond draw_arc(width/2,height/2,120,0,m*radians(6));//Minute draw_arc(width/2,height/2,200,0,hou*radians(30));//Hour //TEXT INSIDE fill(#18AA31); text(addzero(s),(width/2)-13,(height/2)+6); text(addzero(m),137,195); text(addzero(h),137,233); //LABEL pushMatrix(); translate(198,233); rotate(radians(310)); text("Hours", 0,0); popMatrix(); pushMatrix(); translate(175,195); rotate(radians(310)); text("Min.", 0,0); popMatrix(); //DIGITAL fill(#0F39FF); String tex=addzero(h) + ":" + addzero(m) + ":" + addzero(s); text(tex,(width/2)-textWidth(tex)/2,30); } void draw_arc(int x,int y,int size,float start,float stop){ stroke(#96BF9D); //bg ellipse(x,y,size,size); stroke(#18AA31); arc(width/2,height/2,size,size,PI+HALF_PI+start,PI+HALF_PI+stop); } String addzero(int timein){ String textime=str(timein); if (timein<10) textime= "0" + timein; return textime; }
วันอังคารที่ 25 สิงหาคม พ.ศ. 2558
Lab02 : Clock
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
commit เพิ่มเติม : เพื่ม userstory, bookmark
>> add userstory ทำการเพิ่ม userstory ใน functional tests >> add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...
-
1 2 3 4 5 6 7 8 9 def setup (): print (d2b( 8 )) def d2b (num): x = "" while num > 0 : x = str ( int (n...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 def test_layout_and_styling ( self ): # Edith goes to the home page self . brow...
-
การใช้ template inheritence คือการสืบทอดเทมเพลต เพื่อให้ไม่ต้องเขียนโค้ดหน้าเว็บๆซ้ำๆ เราจะมีหน้าหลักอันเดียว (base.html or parent) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น