Nec plus ultra, Michael !
No flickerings during the loop, absoultely perfect. Even X and Y are professionally set.
I thought that Sprites were only for games' screens, apparently it can also be used in normal applications. I have to study this closer, as it has his advantages.
I added a progress bar.
The progress bar is flickering, what should I do to avoid it flickering?
Code: Select all
;(c) Michael Vogel
#ScreenMode=2
Enumeration
#Window
#Image_Gadget
#Image_Gradient
#Image_Text
#Font
#ProgBar
EndEnumeration
Procedure ImageGadgetText(gadget,background,text.s,mode=#False,color=#Black,shadow=0)
Protected x,y
If mode
StartDrawing(ScreenOutput())
DrawImage(ImageID(background),0,0)
Else
CopyImage(background,#Image_Text)
StartDrawing(ImageOutput(#Image_Text))
EndIf
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(FontID(#Font))
x=(ImageWidth(background)-TextWidth(text))>>1
y=(ImageHeight(background)-TextHeight(text))>>1
If Shadow=2
DrawText(X+2,Y+2,Text,$202020); double shadow always dark gray
EndIf
If Shadow=2 Or Shadow=1
DrawText(X+1,Y+1,Text,$000000) ;shadows always black
EndIf
DrawText(X,Y,Text.s,Color)
StopDrawing()
If mode
FlipBuffers()
Else
SetGadgetState(gadget,ImageID(#Image_Text))
EndIf
EndProcedure
Procedure ImageGradient(image,w,h)
CreateImage(image,w,h,32)
StartDrawing(ImageOutput(image))
Box(0,0,w,h,$FFFFFF)
DrawingMode(#PB_2DDrawing_Gradient)
BackColor($0000FF)
GradientColor(0.4, $00FFFF)
GradientColor(0.6, $FFFF00)
FrontColor($FF0000)
LinearGradient(0,0,w,h)
Box(0,0,w,h)
StopDrawing()
ProcedureReturn ImageID(image)
EndProcedure
LoadFont(#Font,"Tahoma",8,#PB_Font_Bold)
Win=OpenWindow(#Window,0,0,600,500,"Drawing Example",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ImageGradient(#Image_Gradient,600,500)
If #ScreenMode
InitSprite()
OpenWindowedScreen(Win,0,0,600,500,0,0,0)
Else
ImageGadget(#Image_Gadget,0,0,600,500,ImageID(#Image_Gradient))
DisableGadget(#Image_Gadget,#True)
EndIf
ImageGadgetText(#Image_Gadget,#Image_Gradient,"A loop 1..1000 will be launched...",#ScreenMode,#White,2)
Delay(1000)
ProgressBarGadget(#ProgBar,10,WindowHeight(#Window)-40,WindowWidth(#Window)-20,30,0,1000,#PB_ProgressBar_Smooth)
For i=1 To 1000
ImageGadgetText(#Image_Gadget,#Image_Gradient,"Program Loop is now at "+Str(i),#ScreenMode)
SetGadgetState(#ProgBar,i)
Next
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow