Strict

Import pantson.morph

Local s:Int
Local ds:Int
Local m1:tmorph
Local m2:tmorph
Local p1:TPixmap
Local p2:TPixmap
Local p:TPixmap

' init images and morphs
p1 = LoadPixmap("me.jpg")
p2 = LoadPixmap("cat.jpg")

m1 = LoadMorph("me.txt")
m2 = LoadMorph("cat.txt")

' frame data
s = 0
ds = 1
Local m:Int

Graphics 800,600,0

While Not KeyDown(key_escape)
	' create a new pixmap from p1 and p2 using morphs m1 and m2.
	' 200 steps (0-199)
	p = MorphPixmaps(p1,m1,p2,m2,99,s)
	
	' draw new pixmap and clear newly generated pixmap instantly.
	If p <> Null
		DrawPixmap p,0,0
		p = Null
		GCCollect
	EndIf
	
	' move frame
	s:+ds
	
	' bounce limits of frames
	If s = 100
		s = 99
		ds = -1
		Print MilliSecs() - m
	EndIf
	
	If s =-1
		s = 0
		ds = 1
		m = MilliSecs()
	EndIf
	
	' gfx flip
	Flip
Wend

' exit
End

