Page 1 of 1

Smooth scroller

Posted: Tue Jan 01, 2019 9:43 pm
by lazi
Non smooth text scrolling on Amiga was always an eye hurting visual effect.
Recently popped up a new upload (gfx/show/Intro-Kreation-001_OS4.lha) on Aminet made with Hollywood which presents text scrolling without perfectly smooth realization.

So I decided to share my little scroller object what uses GLGalore to achieve really smooth scrolling effect.

Feel free to use it anywhere, anyhow.

Code: Select all

@APPAUTHOR "Zoltan Lazar"
@APPTITLE "Demoscroller object"
@APPDESCRIPTION "Flickering free text scroller object"
@APPVERSION "$VER: scroller 1.0 (08-Jan-18)"
@DISPLAY {mode="fullscreen",width=640, height=480, color=#WHITE}
@REQUIRE "glgalore.hwp"
BeginDoubleBuffer(True)

demo_scroller={}
Function demo_scroller:setup()
	self.fontinfo=0
	self.text="Amiga Rulez Forever - Greetings goes to: Andreas Falkenhahn a.k.a. softwerfailure for Hollywood - Norbert Roecher a.k.a. Bit Arts for the timeless mod Wasteland - Trevor Dickinson for keeping alive and rolling forward Amiga - WhdLoad should be transferred back to the past which can alone change the future to an alternative present where more Amiga is kicking... and now start it again....                              "
	self.text=UpperStr(self.text)
	self.width=40
	self.window=0
	self.length=640
	self.pos=0
 
	self.ascii2path = Function()
							  SetFillStyle(#FILLGRADIENT,#LINEAR,#RED,#YELLOW)
							  SetFormStyle(#EDGE,#WHITE,2)
							  SetFormStyle(#ANTIALIAS)
							  SetFormStyle(#SHADOW,#GRAY,3,#SHDWSOUTHEAST)

							  SetFont(#MONOSPACE,50)
							  
							  Local f={}
							  Local tbr
							  ; 21 - 7E
							  For Local i=$21 To $7E
								  StartPath(i)
								  MoveTo(i,0,0)
								  AddTextToPath(i,Chr(i))
								  ClosePath(i)
								  ss=TextExtent(Chr(i))
								  InsertItem(f,TextExtent(Chr(i)),i)


								  tbr=CreateBrush(Nil,40,80,#WHITE)
								  SelectBrush(tbr)
								  DrawPath(i,#CENTER,ss.height)
								  EndSelect
								  CopyBrush(tbr,i,{hardware=True})
								  FreeBrush(tbr)
							  Next
							  Return(f)
						EndFunction

	self.fontinfo = self.ascii2path()

	self.sintable = {}

	For Local i=0 To 179 self.sintable[i]=Sin(Rad(i))+.5 Next

	self.draw = Function ()
					Local chars, charpos, c, x, y
					chars=Min(self.pos\self.width+1,self.length\self.width+1)
					charpos=self.pos\self.width

					For Local i=charpos-chars To charpos

					If i>=0
						c=Asc(MidStr(self.text,i,1))
						y=300
						x=self.length-self.pos+i*self.width

						If c<>32 Then DisplayBrush(c,x,y)

					EndIf

					Next
					self.pos=Wrap(self.pos+2,0,self.width*(StrLen(self.text)-1))


				EndFunction
EndFunction
demo_scroller:setup()



Repeat
		DisableLineHook()
		Cls(#WHITE)
			demo_scroller.draw()
		Flip
		EnableLineHook()
		CheckEvent
Forever

                                                               
Image

Re: Smooth scroller

Posted: Wed Jan 02, 2019 6:38 pm
by airsoftsoftwair
Yes, this is possible thanks to MiniGL and TinyGL :)