Code: Select all
;*********************************************
; PureBasic Community: Evolving code
; January 26, 2010
; Nituvious - initial seed
; Trond - changed textgadget to imagegadget
; JackWebb - cleanup
; Nituvious - scrolls the text
; c4s - cleanup
; Trond - bug fix
; citystate - color cycling
; happer66 - syntax fix
;*********************************************
; EnableExplicit
Enumeration
#Font
#Image
#WindowMain
#GadgetImage
EndEnumeration
Define iWidth.l = 300
Define iHeight.l = 200 ; Maybe someone can think up something cool to do with this :)
Define Text.s = "The PureBasic Community rocks!"
Define TextX.f, TextY.f
Define I, ColorI, Color, count
Define EventID
LoadFont(#Font, "Verdana", 11, #PB_Font_Bold | #PB_Font_Italic)
If CreateImage(#Image, iWidth, iHeight)
StartDrawing(ImageOutput(#Image))
DrawingFont(FontID(#Font))
Box(0, 0, iWidth, iHeight, RGB(0, 0, 0))
For I = Len(Text) To 0 Step -1
ColorI = 255 - (I * 255) / Len(Text)
Color = RGB(ColorI, 255 - ColorI, ColorI)
DrawText(10, (iHeight / 2) - 20, Left(Text, I), Color, RGB(0, 0, 0))
Next
StopDrawing()
EndIf
OpenWindow(#WindowMain, #PB_Ignore, #PB_Ignore, iWidth, iHeight, "PB Community: Evolving code", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(#WindowMain, RGB(0, 0, 0)) ; Give us a black background for our moving text
ImageGadget(#GadgetImage, 0, 0, 0, 0, ImageID(#Image))
Repeat
; cycle the colors
StartDrawing(ImageOutput(#Image))
DrawingFont(FontID(#Font))
Box(0, 0, iWidth, iHeight, RGB(0, 0, 0))
For I = Len(Text) To 0 Step -1
ColorI = 255 - ((I + count) * 255) / Len(Text)%256
Color = RGB(ColorI, 255 - ColorI, ColorI)
DrawText(10, (iHeight / 2) - 20, Left(Text, I), Color, RGB(0, 0, 0))
Next: count+1
StopDrawing(): SetGadgetState(#GadgetImage,ImageId(#Image))
; Silly Scrolling Marquee thingy
EventID = WaitWindowEvent(1)
If ElapsedMilliseconds() > prevtickcount+10
prevtickcount = ElapsedMilliseconds()
y.i = (GetTickCount_() / 30) % (iHeight+40) ; 30 is the inverse speed of the scrolling effect
ResizeGadget(#GadgetImage, #PB_Ignore, -iHeight/2-20+y, #PB_Ignore, #PB_Ignore)
EndIf
Until EventID = #PB_Event_CloseWindow
Thanks for letting me in!(untested, but I think it should work)
