Multi colored ProgressBarGadget

Just starting out? Need help? Post your questions and find answers here.
normeus
Enthusiast
Enthusiast
Posts: 472
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Multi colored ProgressBarGadget

Post 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
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
dibor
Enthusiast
Enthusiast
Posts: 160
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: Multi colored ProgressBarGadget

Post 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
Mac Studio M1Max, PB 6.12 Arm64 and x64.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Post Reply