Page 2 of 2
Re: Multi colored ProgressBarGadget
Posted: Sat May 04, 2024 9:57 pm
by normeus
You are right, going from bottom to top looks much better. Change the Box drawing line to start from bottom like this:
Code: Select all
Box(0,100-i,50,2, RGB(000+a,255-b,000)) ;<----- 100 is the size of the bar so we paint backwards change it to the size of your bar
Norm
Re: Multi colored ProgressBarGadget
Posted: Sun May 05, 2024 10:20 pm
by dibor
Here Modified example code of BP for vertical gradient progress bar
Code: Select all
#Bar_W = 30
#Bar_H = 400
#Canvas = 1
Procedure DRAW_BAR()
Static scale.i = #Bar_H / 100
Static bias.i = 7
Static amp.i = 50
amp + Random(16) - bias
If amp < 50
amp = 50 : bias = 7
ElseIf amp > 100
amp = 100 : bias = 9
EndIf
StartDrawing(CanvasOutput(#Canvas))
DrawingMode(#PB_2DDrawing_Gradient)
BackColor($00FF00)
GradientColor(0.5, $00FF80)
GradientColor(0.7, $00FFFF)
FrontColor($0000FF)
LinearGradient(0, #Bar_H, 0, 0)
Box(0, #Bar_H - amp * scale , #Bar_W, #Bar_H )
DrawingMode(#PB_2DDrawing_Default)
Box(0, 0, #Bar_W, #Bar_H - amp * scale, 0)
StopDrawing()
EndProcedure
If OpenWindow(0,0,0,#Bar_W+20,#Bar_H+20,"",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
AddWindowTimer(0,0,100)
CanvasGadget(#Canvas, 10, 10, #Bar_W + 4, #Bar_H + 4, #PB_Canvas_Border)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow : Break
Case #PB_Event_Timer : DRAW_BAR()
EndSelect
ForEver
EndIf
Thanks to ALL