Thanks for the input, degac your code got me thinking about some different things and here is the splash screen I came up with if anyone is interested.
Type TSplash
Global list:TList= CreateList()
Const alphaMax# = 1
Const alphaMin# = 0
Const fOUT = 0
Const fIN = 1
Field image:TImage
Field alpha#
Field fade_duration
Field hold_duration
Field milli
Field mode
Function Create:TSplash(img:Object, width=800, Height=600)
'
' CODE BELOW CREATES THE IMAGE THAT WILL BE FADED
' CHANGE TO SUIT YOUR NEEDS
'
Local image0:TImage = LoadImage(img)
If not image0 Then RuntimeError("Unable to load splash logo!")
Local image1:TImage = CreateImage(width,Height,1,DYNAMICIMAGE|MASKEDIMAGE)
MidHandleImage image0
SetClsColor (255 , 255 , 255)
Cls
DrawImage image0, width/2, Height/2
GrabImage image1, 0, 0
SetClsColor(0,0,0)
Local splash:TSplash=New TSplash
splash.image = image1
splash.alpha = 1
splash.fade_duration = 2000
splash.hold_duration = 3000
splash.milli = MilliSecs()
splash.mode = splash.fOUT
ListAddLast list,splash
Return splash
End Function
Method SetFadeIn(hd=2000, fd=2000)
alpha = 0
milli = MilliSecs()
hold_duration = hd
fade_duration = fd
mode = fIN
End Method
Method SetFadeOut(hd=2000, fd=2000)
alpha = 1
milli = MilliSecs()
hold_duration = hd
fade_duration = fd
mode = fOUT
End Method
Function Update()
Local stillGoing = False
Local r
For Local s:TSplash=EachIn list
r = s.Draw()
If not r Then stillGoing=True
Next
If not stillGoing
For Local s:TSplash=EachIn list
s.image = Null
s.list.Remove s
Next
EndIf
Return stillGoing
End Function
Method Draw()
Local tt# , tl# 'total time, time left
Local r# 'result
If mode = fOUT
If MilliSecs() > hold_duration + milli
If MilliSecs() > fade_duration + hold_duration + milli Return 1
tt# = fade_duration + hold_duration + milli
tl# = tt - MilliSecs()
r# = Abs((tl / fade_duration) )
If r <= 0 Return 1
alpha = r
EndIf
EndIf
If mode = fIN
If MilliSecs() > fade_duration + hold_duration + milli Return 1
tt# = fade_duration + hold_duration + milli
tl# = tt - MilliSecs()
r# = Abs((tl / fade_duration) )
Print r
If r <= 0 Return 1
alpha = r
EndIf
Local prevBlend = GetBlend()
SetAlpha(alpha)
SetBlend(ALPHABLEND)
DrawImage image , 0 , 0
SetBlend(prevBlend)
SetAlpha(1)
EndMethod
End Type
'
'test
'
Graphics 800,600
'fade out demo
'SetFadeOut(hold_duration, fade_duration)
'hold duration = length to hold graphic before fading OUT (in millisecs)
'fade duration = how long should the fade take to fade out (in millisecs)
Local splash:TSplash=TSplash.Create("image.png")
splash.SetFadeOut(2000 , 1000)
Local done = False
While not done
Cls
If not TSplash.Update() done = True
Flip
Wend
'fade in demo
'SetFadeIn(hold_duration, fade_duration)
'hold duration = length to hold graphic AFTER fading in (in millisecs)
'fade duration = how long should the fade take to fade in(in millisecs)
splash:TSplash=TSplash.Create("image.png")
splash.SetFadeIn(2000 , 1000)
done = False
While not done
Cls
If not TSplash.Update() done = True
Flip
Wend
End
|