Liberty BASIC Community Forum
Liberty BASIC Programming Discussions >> Liberty BASIC Code >> CountDown indicator similiar old movie
http://libertybasic.conforums.com/index.cgi?board=LB3&action=display&num=1515705965

CountDown indicator similiar old movie
Post by xtal on Jan 11th, 2018, 3:26pm

I was looking for a dis-tractor while supplying a delay, and came up with this....



Code:
[WindowSetup]
  NOMAINWIN                                                          '    allow no print window
    WindowWidth = 1020 : WindowHeight = 700   '877
global oldx, oldy
graphicbox  #main.Plot3, 476, 235, 525,405                             ' home is 0,405

Open "Liberty Basic GRBL GUI" for Window as #main                      '
   #main "trapclose [quit]"                                           '
   cxx=261 : cyy=201 : Rl=70 : Rc = 80                                   ' x,y center & Radius & PI
   #main.Plot3,"down; home; posxy cxx cyy"                     ' circle line size
   oldx=cxx : oldy=cyy
   #main.Plot3,"color black; font arial 80"                                         '

 for zzz= 5 to 0 step -1
   if zzz=0 then
     Q=Ln1(Rl,Rc,cxx,cyy,zzz,"green")
   else
     Q=Ln1(Rl,Rc,cxx,cyy,zzz,"black")
   end if
 next zzz

[quit]
timer 2000,[xit]
wait
[xit]
 close #main
 end
'==================================================================================================================
function Ln1(Rl,Rc,cxx,cyy,zzz,Z$)                         '  LINE AND CIRCLE COUNT DOWN
       PI=acs(-1)                                          '
       for t=3*PI to PI step PI/-60  '  CW top^            ' for t=PI to 3*PI step PI/60  '  CCW top^
       'for t=0 to 2*PI step PI/60   '  CCW bottom v       ' for t=2*PI to 0 step PI/-60  '  CW  bottom v
        ry=(Rc)*cos(t)+cyy                                 '  Y CIRCLE COMPUTE
        rx=(Rc)*sin(t)+cxx                                 '  X CIRCLE COMPUTE
 ' UN REM the next 2 lines for interesting pattern------------------------------------------------------------------
 '  y=Rl*cos(t)+cyy : oldy=y                               '  Y  LINE COMPUTE & SAVE
 '  x=Rl*sin(t)+cxx : oldx=x                               '  X  LINE COMPUTE & SAVE
        #main.Plot3,"size 2; color white"                  '
        #main.Plot3,"home; goto ";oldx;" ";oldy            '  ERASE PREVIOUS LINE
        y=Rl*cos(t)+cyy : oldy=y                           '  Y  LINE COMPUTE & SAVE
        x=Rl*sin(t)+cxx : oldx=x                           '  X  LINE COMPUTE & SAVE
        #main.Plot3,"color black; home; goto ";x;" "; y    '  DRAW NEWLINE size 2
        #main.Plot3,"size 10; color ";Z$                   '  SETUP CIRCLE size 10
        #main.Plot3,"set ";rx;" ";ry                       '  PLOT CIRCLE
        #main.Plot3, "place 231 242; size 2; color black"  '  Place NUMBER
        #main.Plot3, "\";zzz                               '  DISPLAY NUMBER
        td=time$("ms")+9                                   '  Attempt 1 second delay
        while time$("ms") < td                             '  Attempt 1 second delay
        wend                                               '  Attempt 1 second delay
      next t                                               '
        #main.Plot3,"size 2; color white"                  '  SETUP LAST LINE  'CLEANUP
        #main.Plot3,"home; goto ";oldx;" ";oldy            '  ERASE LAST LINE  'CLEANUP
        #main.Plot3, "place 231 242; size 2; color black " '  SETUP DIGET      'CLEANUP
        #main.Plot3, "\";zzz                               '  DISPLAY DIGIT    'CLEANUP
end function                                               '
'------------------------------------------------------------------------------------------------------------------

 

Re: CountDown indicator similiar old movie
Post by tsh73 on Jan 12th, 2018, 12:24am

Nice effect, thanks.
Alternating color ring:
Code:
 colr$="black white black white black white black white "
 for zzz= 5 to 0 step -1
   if zzz=0 then
     Q=Ln1(Rl,Rc,cxx,cyy,zzz,"green")
   else
     Q=Ln1(Rl,Rc,cxx,cyy,zzz,word$(colr$, zzz))
   end if
 next zzz 

Re: CountDown indicator similiar old movie
Post by BeeTrap on Jan 12th, 2018, 08:20am

Thanks for this. I will use this as a "progress indicator". I don't like programs that don't let the user know if it is running properly or just idle for no reason.