אפריל 30th, 2010התוכנית הראשונה שלי בprocessing
בתחילת השבוע הוצג בלינמגזין פוסט על שפת processing שניתן לתכנת איתה דברים גרפים בקלות. היום התקנתי אותה ויצרתי בה שעון אנלוגי פשוט:
void setup(){
size(640, 360, P3D);
noStroke();
}
void draw(){
int s = second();
int m = minute();
int h = hour();
int r = 150;
int x0 =150;
int y0 =150;
background(0);
lights();
arc(x0,y0,r, r,0, 2*PI);
stroke(100);
line(x0, y0, (r-100)*cos(s*2*PI/60-PI/2)+x0, (r-100)*sin(s*2*PI/60-PI/2)+y0);
line(x0, y0, (r-115)*cos((m*60+s)*2*PI/3600-PI/2)+x0, (r-115)*sin((m*60+s)*2*PI/3600-PI/2)+y0);
line(x0, y0, (r-120)*cos((h*3600+m*60+s)*2*PI/(3600*12)-PI/2)+x0, (r-120)*sin((h*3600+m*60+s)*2*PI/(3600*12)-PI/2)+y0);
}
Uploaded with ImageShack.us
