Progress bar algorithm

BlitzPlus Forums/BlitzPlus Programming/Progress bar algorithm

William Drescher(Posted 2007) [#1]
Does anyone have an algorithm for progress bars that will tell you how much of the bar is filled and will evenly fill it depending on the size of the graphics.

Graphics 800,600

x = 0
While x<GraphicsWidth()-20
Cls
Color 255,255,255
Text 0,0,"Please wait - Loading data..."
Color 0,128,255
Rect 10,(GraphicsHeight()-20)/2,GraphicsWidth()-20,20,0
Rect 10,(GraphicsHeight()-20)/2,x,20,1
Color 255,255,255
x = x + 1
Flip
Wend
EndGraphics
End


The maximum number for the progress bar should be 100, so the While part should be "While x<100".


CS_TBL(Posted 2007) [#2]
Not sure whether I understand your question.

currentprogressbarpixels=filesize*loadedamountofdata/maxprogressbarpixels
Rect 0,0,currentprogressbarpixels,20

..something like this..?