1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
'
' Provides text fade routines
'
' $Id$
'
Import noddybox.bitmapfont
Type TFontFade
Field list:TList
Field font:TBitmapFont
Function Create:TFontFade(f:TBitmapFont)
Local ff:TFontFade=New TFontFade
ff.list=New TList
ff.font=f
Return ff
End Function
Method Add(s:String, x:Float, y:Float, col:Int, a:Float=1.0, ai:Float=0.02, dx:Float=0.0, dy:Float=0.0)
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=1.0, ai:Float=0.02, dy:Float=0.0)
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.Centre(f.s,f.y,f.r,f.g,f.b)
Else
font.Draw(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
|