From f6b1934a27375bb633e70757d672eae1e3485f5a Mon Sep 17 00:00:00 2001 From: Ian C Date: Tue, 14 Jun 2005 00:21:33 +0000 Subject: *** empty log message *** --- font_fade.bmx | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 font_fade.bmx (limited to 'font_fade.bmx') diff --git a/font_fade.bmx b/font_fade.bmx new file mode 100644 index 0000000..62f5e82 --- /dev/null +++ b/font_fade.bmx @@ -0,0 +1,108 @@ +' +' Provides text fade routines +' +' $Id$ +' +Type FontFade + Field list:TList + Field font:BitmapFont + + Function Create:FontFade(f:BitmapFont) + Local ff:FontFade=New FontFade + + ff.list=New TList + ff.font=f + + Return ff + End Function + + Method Add(s:String, x:Float, y:Float, col:Int, a:Float, ai:Float, dx:Float, dy:Float) + Local f:FontFadeEnt=New FontFadeEnt + + f.s=s + f.x=x + f.y=y + f.dx=dx + f.dy=dy + f.r=(col & $ff0000) Shr 16 + f.g=(col & $ff00) Shr 8 + f.r=(col & $ff) + f.a=a + f.ai=ai + f.centre=False + + list.AddLast(f) + End Method + + Method Centre(s:String, y:Float, col:Int, a:Float, ai:Float, dy:Float) + Local f:FontFadeEnt=New FontFadeEnt + + f.s=s + f.x=0 + f.y=y + f.dx=0 + f.dy=dy + f.r=(col & $ff0000) Shr 16 + f.g=(col & $ff00) Shr 8 + f.b=(col & $ff) + f.a=a + f.ai=ai + f.centre=True + + list.AddLast(f) + End Method + + Method Clear() + list.Clear() + End Method + + Method IsEmpty:Int() + Return list.IsEmpty() + End Method + + Method Count:Int() + Return list.Count() + End Method + + Method Process() + Local a:Float=GetAlpha() + + For Local f:FontFadeEnt=EachIn list + If f.a<0.001 And f.ai<0 + list.Remove(f) + Else + SetAlpha(f.a) + + If f.centre + font.CentreColoured(f.s,f.y,f.r,f.g,f.b) + Else + font.DrawColoured(f.s,f.x,f.y,f.r,f.g,f.b) + EndIf + + f.a:+f.ai + f.x:+f.dx + f.y:+f.dy + + If f.a>1 + f.a=1 + f.ai=-f.ai + EndIf + EndIf + Next + + SetAlpha(a) + End Method + +End Type + +Type FontFadeEnt + Field s:String + Field x:Float + Field y:Float + Field dx:Float + Field dy:Float + Field r,g,b:Int + Field a:Float + Field ai:Float + Field centre:Int +End Type \ No newline at end of file -- cgit v1.2.3