Main Menu

X & Y Text Sine Wave

Started by kevin, December 29, 2021, 09:25:02 AM

Previous topic - Next topic

kevin


  X & Y Text Sine Wave


PlayBASIC Code: [Select]
; PROJECT : Xand Y sine wave text renering test
; AUTHOR : Kev Picone - http://playbasic.com
; CREATED : 30/12/2021
; EDITED : 30/12/2021
; ---------------------------------------------------------------------


if GetFontStatus(50)=false
LoadFont "Agency FB",50,148,1,8
FontDrawmode 50,1
endif


setfps 20
screen=newfximage(getscreenwidth(),getscreenheight())

Message$="Sine Wave X&Y Axis"
FadeLevel#=1
Do
;cls
rendertoimage screen
cls $112233
setfont 50
ShadedText(Screen,100,Message$, FadeLevel#)
rendertoscreen

fadeangle#=wrapangle(fadeangle#,0.5)
FadeLevel#= 0.5+sin(fadeangle#)
drawimage screen,0,0,false

sync
loop spacekey()=true or esckey()=true


end




Function ShadedText(Screen,Ypos,Message$, FadeLevel#)
oldSurface =getSurface()

Static WobbleAngle#
Static WobbleAngle2#


Static VertialWobbleAngle#

rendertoimage screen


//FadeLevel#=cliprange(FadeLevel#,0,1)

screenwidth =GetSurfaceWidth()
screenHeight=GetSurfaceHeight()


imageviewport Screen,0,0,screenWidth,ScreenHeight

TW=GetTextWidth(Message$)

Xpos=(ScreenWidth/2)-(TW/2)

ThisRGB=rgb(50,50,50)



Level = Cliprange( ($90*FadeLevel#) , 0,255)
if level>0
for lp =0 to 2
ink rgbfade(ThisRgB,50) or Argb(Level,0,0,0)
text Xpos,Ypos,Message$
Level+=$16
Xpos+=2
Ypos+=1
next
endif
Rgb1=rgb(20,70,170)
Rgb2=rgb(220,230,250)

Rows=GetTextHeight("|")

Alpha = Cliprange( ($ff*FadeLevel#) , 0,255)

if Alpha>0
TextWidthInPixels = GetTextWidth(Message$)
VerticalWaveChunkSize = 4

VerticalRows=Rows+16
For lp =0 to VerticalRows ;Rows+16
scaler#=float(lp)/VerticalRows

scaler#*= cos(WobbleAngle#)+0.5

ThisRGB=RgbAlphaBlend(Rgb1,RGB2,Scaler#*100) and $00ffffff
ink lsl32(Alpha,24) or ThisRGB


Ypos2=Ypos+lp

OffsetX =Cos(WobbleAngle#+(lp*1))*5
OffsetX +=Sin(WobbleAngle2#-(lp/5))*3


// draw this strip with

for xwave=0 to TextWidthInPixels step VerticalWaveChunkSize


VerticalOffset =sin(VertialWobbleAngle#+(Xwave*0.5))*20
; VerticalOffset+=cos(VertialWobbleAngle#+(Xwave*0.3))*4

;cosradius(WobbleAngle#,12)

ScreenX1 = xwave+xpos+OffsetX
ScreenX2 = ScreenX1+VerticalWaveChunkSize
FinalYpos =Ypos2+VerticalOffset
imageviewport Screen,ScreenX1,ypos2,ScreenX2,Ypos2+1

text Xpos+OFFSETX,ypos+VerticalOffset,Message$
next
next

endif

imageviewport Screen,0,0,screenWidth,ScreenHeight

WobbleAngle#=wrapangle(WobbleAngle#,2.5)
WobbleAngle2#=wrapangle(WobbleAngle2#,1.5)


VertialWobbleAngle#= wrapangle(VertialWobbleAngle#,0.5)

rendertoimage oldSurface


endFunction