Programming problem with graphics
11-21-2014, 05:00 PM
Post: #4
 DrD Senior Member Posts: 1,124 Joined: Feb 2014
RE: Programming problem with graphics
No expert but, using just G0, and something like this could be a start:

Code:
#pragma mode( separator(.,;) integer(h32) ) EXPORT Uhr() BEGIN   LOCAL Tm,Hr,Mn,Sc,Mm,Ll;   LOCAL fs,fm,fh;  // flag to redraw clock hands   RECT(G0); // Draw clock face   FOR Mm FROM 0 TO 59 STEP 1 DO     IF Mm MOD 5 == 0 THEN       Ll := 8;     ELSE       Ll := 4;     END;       LINE_P(G0,ROUND(160+SIN(2*π*Mm/60)*(120-Ll),0),ROUND(120-COS(2*π*Mm/60)*(120-Ll),0),ROUND(160+SIN(2*π*Mm/60)*(120),0),ROUND(120-COS(2*π*Mm/60)*(120),0),RGB(192,192,192));   END; // Initialize time flags (hand redraws)   Tm := approx(Time);   fh:=FLOOR(2*π*(Tm MOD 12)/12);   fm:=FLOOR(FP(Tm)*60);   fs:=FLOOR(FP(Tm)*60^2);   // Update real time   REPEAT     Tm := approx(Time);     Hr := 2*π*(Tm MOD 12)/12;     Mn := FP(Tm)*60;     Sc := FP(Mn)*60; //  RECT(G1); // Manage clock hands     IF FLOOR(Hr)==fh then       LINE_P(G0,160,120,ROUND(160+SIN(fh)*60,0),ROUND(120-COS(fh)*60,0),RGB(0,0,0));                       // Draw Hour hand     ELSE        LINE_P(G0,160,120,ROUND(160+SIN(fh)*60,0),ROUND(120-COS(fh)*60,0),RGB(255,255,255));                // Clear Hour hand        fh:=FLOOR(Hr);  // Reset flag     END;     IF FLOOR(Mn)==fm then       LINE_P(G0,160,120,ROUND(160+SIN(2*π*fm/60)*80,0),ROUND(120-COS(2*π*fm/60)*80,0),RGB(0,0,255));       //  Draw Minute hand     ELSE        LINE_P(G0,160,120,ROUND(160+SIN(2*π*fm/60)*80,0),ROUND(120-COS(2*π*fm/60)*80,0),RGB(255,255,255));   // Clear Minute hand       fm:=FLOOR(Mn);  // Reset flag     END;      IF FLOOR(Sc)==fs then           LINE_P(G0,160,120,ROUND(160+SIN(2*π*fs/60)*100,0),ROUND(120-COS(2*π*fs/60)*100,0),RGB(255,0,0));     // Draw Second hand           ELSE       LINE_P(G0,160,120,ROUND(160+SIN(2*π*fs/60)*100,0),ROUND(120-COS(2*π*fs/60)*100,0),RGB(255,255,255)); // Clear old Second hand       fs:=FLOOR(Sc);   // Reset flag                                                                                                          END;      BLIT_P(G0,0,0,320,240,G1,0,0,320,240);     UNTIL GETKEY ≥ 0;   FREEZE;  END;
 « Next Oldest | Next Newest »

 Messages In This Thread Programming problem with graphics - ww63 - 11-21-2014, 01:30 PM RE: Programming problem with graphics - Han - 11-21-2014, 03:37 PM RE: Programming problem with graphics - ww63 - 11-21-2014, 03:55 PM RE: Programming problem with graphics - DrD - 11-21-2014 05:00 PM

User(s) browsing this thread: 1 Guest(s)