News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Wobbly text - source included

Started by monkeybot, January 10, 2014, 05:48:45 AM

Previous topic - Next topic

monkeybot

This is a wobbly text thing...



kevin

#1
 Why not post this in the source board ??  -  Setting the viewport is generally a better approach.   Although, what you could do is make a bitmap/crf fonts out each message, where each row is a single row of pixels high.  Which is most likely faster again and gives colour control.  

PlayBASIC Code: [Select]
LoadFont  "veranda",2,100,0,8
Setfont 2

do
cls

lockbuffer
For lp=0 to 599
screenviewport 0,lp,800,lp+1
offset=sin(Baseangle+lp)*50

ypos=(lp/100)*100
text 200+offset,ypos,"hello world"
next
unlockbuffer

Baseangle=wrapangle(Baseangle+1)
restoreimageviewport 0

Sync
loop





   CRF version

PlayBASIC Code: [Select]
   LoadFont  "veranda",2,100,0,8
Setfont 2

MessageHeight=100

; create a empty bitmap font in FX format
StripFont =NewBitMapFont(600,1,4)

; make a temp fx image 1 strip high
TempImage=NewfxImage(600,1,1)

; render to the temp strip
rendertoimage TempImage

; grab the rows of the message as characters in the font
For ylp=0 to getfontheight(2)
cls 0
ink -1
text 0,-ylp,"Hello World"
getfontchr StripFOnt,32+ylp,0,0
next

; convert FX bitmap font to CRF
makebitmapfont StripFont,-1,8
rendertoscreen

; throw the temp image away
deleteimage TempIMage

; set the strip font as the current
setfont StripFont

; --------------------------------------------------------
; draw the demo scene
; --------------------------------------------------------
do
cls

lockbuffer
For lp=0 to 599
Row=Mod(lp,MessageHeight)
offset=sin(Baseangle+lp)*50
text 200+offset,lp,chr$(32+Row)
next
unlockbuffer

ink rgbfade($ffffff,50+COs(BAseangle)*50)

Baseangle=wrapangle(Baseangle+1)

Sync
loop esckey()





    Since it's CRF the colour can be dynamically controlled

PlayBASIC Code: [Select]
   LoadFont  "veranda",2,100,0,8
Setfont 2

MessageHeight=100

; create a empty bitmap font in FX format
StripFont =NewBitMapFont(600,1,4)

; make a temp fx image 1 strip high
TempImage=NewfxImage(600,1,1)

; render to the temp strip
rendertoimage TempImage

; grab the rows of the message as characters in the font
For ylp=0 to getfontheight(2)
cls 0
ink -1
text 0,-ylp,"Hello World"
getfontchr StripFOnt,32+ylp,0,0
next

; convert FX bitmap font to CRF
makebitmapfont StripFont,-1,8
rendertoscreen

; throw the temp image away
deleteimage TempIMage

; set the strip font as the current
setfont StripFont

; --------------------------------------------------------
; draw the demo scene
; --------------------------------------------------------
do

cls

Baseangle=wrapangle(Baseangle+1)

lockbuffer
For lp=0 to 599
CurrentAngle=BaseAngle+lp

Row=Mod(lp,MessageHeight)
offset=sin(Currentangle)*50

ink rgbfade($ffffff,50+COs(Currentangle)*50)
text 200+offset,lp,chr$(32+Row)
next
unlockbuffer


Sync
loop esckey()







monkeybot

#2
oh yeah sorry,can you move it?
thanks for the tips.
Thanks for moviing it.