Dibuja un reloj en funcionamiento usando círculos.
Este ejemplo usa la instrucción CIRCLE para dibujar líneas rectas creando las manecillas de un reloj y las marcas de verificación alrededor de la esfera del reloj
'Author : Terry Ritchie
'--------------------------------
'- Variables
'--------------------------------
CONST GRAY = _RGB32(127, 127, 127) ' define colors
CONST DARKGRAY = _RGB32(63, 63, 63)
CONST LIGHTGRAY = _RGB32(191, 191, 191)
CONST BLACK = _RGB32(0, 0, 0)
CONST WHITE = _RGB32(255, 255, 255)
CONST RED = _RGB32(127, 0, 0)
CONST YELLOW = _RGB32(255, 255, 0)
DIM Clock!(60) ' 60 radian points around circle
DIM Tick% ' counter to keep track of tick marks
DIM Tc~& ' tick mark color
DIM Radian! ' FOR...NEXT radian counter
DIM h% ' value of hour extracted from TIME$
DIM m% ' value of minute extracted from TIME$
DIM s% ' value of second extracted from TIME$
DIM Tm$ ' current TIME$ value
'--------------------------------
´ - Programa
'--------------------------------
Screen _NewImage(640, 480, 32) ' initiate graphics screen
Tick% = 15 ' first position is 15 seconds
For Radian! = 6.2831852 To 0 Step -.10471975 ' clockwise from 2*Pi in steps of -60ths
Clock!(Tick%) = Radian! ' save circle radian seconds position
Tick% = Tick% + 1 ' move to next seconds position
If Tick% = 60 Then Tick% = 0 ' reset to 0 seconds position if needed
Next Radian!
Do ' begin main loop
Cls ' clear the screen
_Limit 5 ' 5 updates per second
Circle (319, 239), 120, GRAY ' draw outer circle of clock
Paint (319, 239), DARKGRAY, GRAY ' paint circle dark gray
Circle (319, 239), 110, BLACK ' draw inner circle of clock
Paint (319, 239), WHITE, BLACK ' paint face bright white
For Tick% = 0 To 59 ' cycle through radian seconds positions
If Tick% Mod 5 = 0 Then Tc~& = BLACK Else Tc~& = LIGHTGRAY ' 5 second ticks are black in color
Circle (319, 239), 109, Tc~&, -Clock!(Tick%), Clock!(Tick%) ' draw radian line from center of circle
Next Tick%
Circle (319, 239), 102, DARKGRAY ' draw circle to cut off radian lines
Paint (319, 239), WHITE, DARKGRAY ' paint face again to remove radian lines
Circle (319, 239), 102, WHITE ' fill in cut off circle
Circle (319, 239), 4, BLACK ' draw small black circle in center
Paint (319, 239), 0, BLACK ' paint small black circle
Tm$ = Time$ ' get current time from TIME$
s% = Val(Right$(Tm$, 2)) ' get numeric value of seconds
m% = Val(Mid$(Tm$, 4, 2)) ' get numeric value of minutes
h% = Val(Left$(Tm$, 2)) ' get numeric value of hours
If h% >= 12 Then h% = h% - 12 ' convert from military time
Color BLACK, WHITE ' black text on bright white background
Locate 19, 37 ' position cursor on screen
Print Right$("0" + LTrim$(Str$(h%)), 2) + Right$(Tm$, 6) ' print current time in face of clock
Color GRAY, BLACK ' white text on black background
Tick% = (h% * 5) + (m% \ 12) ' calculate which hour hand radian to use
Circle (319, 239), 80, BLACK, -Clock(Tick%), Clock(Tick%) ' display hour hand
h% = h% + 6 ' move to opposite hour on clock face
If h% >= 12 Then h% = h% - 12 ' adjust hour if necessary
Tick% = (h% * 5) + (m% \ 12) ' calculate which hour hand radian to use
Circle (319, 239), 15, BLACK, -Clock(Tick%), Clock(Tick%) ' display small opposite tail of hour hand
Circle (319, 239), 95, BLACK, -Clock(m%), Clock(m%) ' display minute hand
m% = m% + 30 ' move to opposite minute on clock face
If m% > 59 Then m% = m% - 60 ' adjust minute if necessary
Circle (319, 239), 15, BLACK, -Clock(m%), Clock(m%) ' display small opposite tail of min hand
Circle (319, 239), 2, RED ' draw small red circle in center
Paint (319, 239), RED, RED ' paint small red circle
Circle (319, 239), 100, RED, -Clock(s%), Clock(s%) ' draw second hand
s% = s% + 30 ' move to opposite second on clock face
If s% > 59 Then s% = s% - 60 ' adjust second if necessary
Circle (319, 239), 25, RED, -Clock(s%), Clock(s%) ' display small opposite tail of sec hand
Circle (319, 239), 1, YELLOW ' draw small yellow circle in center
PSet (319, 239), YELLOW ' fill in small yellow circle
_Display ' update screen with loop's changes
Loop Until InKey$ <> "" ' end program when key pressed
System ' return to Windows