smallbasic - How do I make a fast refreshing counter? -
i'm trying make refreshing counter... take example - let's use position of mouse (within window).
i've tried clearing , redrawing bugs out when there many elements draw.
a = 1 while(a = 1) program.delay(10) graphicswindow.clear() graphicswindow.drawtext(10,10,mouse.mousex) graphicswindow.drawtext(10,20,mouse.mousey) endwhile
which works... except flashes because refreshing fast... if increase delay, not work correctly, when doing stopwatch. thing cannot support large amount of commands... like:
a = 1 while(a = 1) program.delay(10) graphicswindow.clear() graphicswindow.drawtext(10,10,mouse.mousex) graphicswindow.drawtext(10,20,mouse.mousey) graphicswindow.drawtext(100,100,"text") graphicswindow.brushcolor = "#ff0000" graphicswindow.drawtext(100,200,"text") graphicswindow.brushcolor = "#00ff00" graphicswindow.drawtext(100,300,"text") graphicswindow.brushcolor = "#0000ff" graphicswindow.drawtext(100,400,"text") graphicswindow.brushcolor = "#000ff0" graphicswindow.drawtext(200,100,"text") graphicswindow.brushcolor = "#ff0000" graphicswindow.drawtext(200,200,"text") graphicswindow.brushcolor = "#0ff000" graphicswindow.drawtext(200,300,"text") graphicswindow.brushcolor = "black" endwhile
which makes big flashing mess... , scrapping graphicswindow.clear() isn't option either because makes overwritten mess...
a = 1 while(a = 1) program.delay(10) graphicswindow.drawtext(10,10,mouse.mousex) graphicswindow.drawtext(10,20,mouse.mousey) endwhile
or this: http://i.stack.imgur.com/4sfss.png
so, question:
is there way make counter can refresh smoothly without flashing can have lots of things drawn in background; elsewhere in window? below, moves.
http://i.stack.imgur.com/azq5t.png
sorry mess of links: not enough reputation post pictures...
you can reduce flashing effect rewriting elements have cleared. example, "delete" text drawing rectangle (which faster graphicswindow.clear()) , drawtext after it.
but way of refreshing produce flashes. better alternative use fremy's fc extension, feature way add "changable" text element (called label) gw. fremy's extension has load of functions sb , makes language usable create actual programs. jquery javascript. highly recommend use it, have to, download *.dll library. more on sb wiki thread.
syntax:
fccontrols.addlabel(width [px], height [px], text)
example:
mylabel = fccontrols.addlabel(100, 30, "loading...") fccontrols.move(mylabel,10,10) while "true" ... fccontrols.settext(mylabel,value) endwhile
this allows refresh text without flashing.
extra hint: can use while "true"
create infinite loops.
Comments
Post a Comment