Page 1 of 1

Progress bar without pixel jumps

Posted: Sat Mar 28, 2026 5:57 pm
by Flinx
Some time ago, I learned that Hollywood’s graphics system can set the position and size of graphic objects only to integer pixel positions. Now I’ve noticed that the function for scaling vector brushes can handle floating-point numbers to achieve the anti-aliasing effect.
This makes it possible to display a progress bar that appears to grow continuously, without any tricks.
The top bar in the example has no anti-aliasing, while the bottom one does:

Code: Select all

@DISPLAY {Width = 400, Height = 150, Layers=True}

SetFillStyle(#FILLCOLOR)
lineWidth=380
lineHeight=15
StartPath(1)
MoveTo(1, 0, 0)
AddBoxToPath(1, 0, 0, lineWidth, lineHeight)
ClosePath(1)

SetFormStyle(#ANTIALIAS)
StartPath(2)
MoveTo(2, 0, 0)
AddBoxToPath(2, 0, 0, lineWidth, lineHeight)
ClosePath(2)

Local id=PathToBrush(Nil, {{ID=1, Color=#WHITE}, {ID=2, Color=#WHITE, X=0, Y=50}})
FreePath(1)
FreePath(2)

xpos=10
ypos=40
TextOut(xpos, 10, "0%", {Name="%"})
DisplayBrush(id, xpos, ypos, {Name="A", Transparency=0})
FreeBrush(id)
For i=0.0001 To 1 Step 0.0003
	BeginRefresh()
	SetLayerStyle("%", {Text=FormatStr("%.2f%%", 100*i)})
	SetLayerStyle("A", {ScaleX=i})
	EndRefresh()
	Sleep(40)
Next

Sleep(5000)
Ralf

Re: Progress bar without pixel jumps

Posted: Fri Apr 03, 2026 5:29 pm
by Juan Carlos
It is a beautiful visual effect, but to make a real progress bar, there are other variables to evaluate, for example, it's to copy a file, the file size, copy ratios, etc., but your visual effect will may to be for a demo, etc.

Re: Progress bar without pixel jumps

Posted: Fri Apr 03, 2026 7:12 pm
by Flinx
Juan Carlos wrote: Fri Apr 03, 2026 5:29 pm there are other variables to evaluate, for example, it's to copy a file, the file size, copy ratios
Take a look at my for loop — there’s a reason it goes from (almost) zero to one. So all you need is a division, for example, the current copy progress divided by the file size.

Re: Progress bar without pixel jumps

Posted: Sat Apr 04, 2026 1:07 pm
by Juan Carlos
Flinx wrote: Fri Apr 03, 2026 7:12 pm
Juan Carlos wrote: Fri Apr 03, 2026 5:29 pm there are other variables to evaluate, for example, it's to copy a file, the file size, copy ratios
Take a look at my for loop — there’s a reason it goes from (almost) zero to one. So all you need is a division, for example, the current copy progress divided by the file size.
Thank you, interesting solution, for the progress bar, I though that it is necessary several variables to have factors to consider include file size, data bus speed, source and destination drive speed, memory buffer size, etc.