I tried taking first character and putting at the end then setting the text but this seemed very jerky.
Remembered how scrolling a canvas in a container seemed ok so tried using a canvas in a container.
Needed two canvas gadgets to get a continuous scroll and threw this together.
My intention is to run the scrolling in a thread (high hopes).
It could be improved sorry for my scrappy code. If anyone can help with improvements please do.
Code: Select all
Global Container_0,Canvas_1,Canvas_2
Global ScrollFont.i
Procedure ScrollText(Text.s)
Static iLoop.i
Static C1Start.i,C2Start.i
Define MyTextWidth.i
If StartVectorDrawing(CanvasVectorOutput(Canvas_1))
VectorSourceColor(RGBA(236,236,236,255))
AddPathBox(0,0,400,200)
FillPath()
VectorFont(FontID(ScrollFont), 20)
VectorSourceColor(RGBA(0, 0, 0, 255))
MyTextWidth = VectorTextWidth(Text)
MovePathCursor(0,0)
DrawVectorText(Text)
StopVectorDrawing()
EndIf
ResizeGadget(Container_0,#PB_Ignore,#PB_Ignore,MyTextWidth,#PB_Ignore)
ResizeGadget(Canvas_1,0,#PB_Ignore,MyTextWidth,#PB_Ignore)
ResizeGadget(Canvas_2,MyTextWidth,#PB_Ignore,MyTextWidth,#PB_Ignore)
While WindowEvent():Wend
If StartVectorDrawing(CanvasVectorOutput(Canvas_2))
VectorSourceColor(RGBA(236,236,236,255))
AddPathBox(0,0,400,200)
FillPath()
VectorFont(FontID(ScrollFont), 20)
VectorSourceColor(RGBA(0, 0, 0, 255))
MovePathCursor(0,0)
DrawVectorText(Text)
StopVectorDrawing()
EndIf
C1Start = MyTextWidth
C2Start = MyTextWidth * 2
iLoop = 0
While iLoop < 5 * MyTextWidth
;Move The Canvas Gadgets
ResizeGadget(Canvas_1,C1Start,#PB_Ignore,#PB_Ignore,#PB_Ignore)
ResizeGadget(Canvas_2,C2Start,#PB_Ignore,#PB_Ignore,#PB_Ignore)
iLoop = iLoop + 1
;Reduce Each Start Point By 1
C1Start = C1Start -1
C2Start = C2Start -1
;If Canvas 1 Off Display
If C1Start < 0 - MyTextWidth
C1Start = C2Start + MyTextWidth
EndIf
;If Canvas 2 Off Display
If C2Start < 0 - MyTextWidth
C2Start = C1Start + MyTextWidth
EndIf
While WindowEvent():Wend
Delay(10)
Wend
EndProcedure
ScrollFont = LoadFont(#PB_Any, "Comic Sans MS", 20)
If OpenWindow(0, 0, 0, 400, 200, "VectorDrawing", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Container_0 = ContainerGadget(#PB_Any, 10, 60, 400, 20)
Canvas_1 = CanvasGadget(#PB_Any, 0, 0, 460, 20)
Canvas_2 = CanvasGadget(#PB_Any, 460, 0, 460, 20)
CloseGadgetList()
ScrollText("The quick brown fox jumps over the lazy dog ")
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
CD