/* Slim_Anim
	Ce script va :
	- construire une animation de 10 images
	- faire un warp sur chaque image.
	- jouer l'animation
	*/

	options results
	parse ARG Port b
	
	ADDRESS value Port

	pp_GetWidth
	width=result

	pp_GetHeight
	height=result

	IF width=0 & height=0 then DO
		pp_Warn 'Load*a*picture*first'
		EXIT
	END

	nbframe=10
	Preview=0
	pp_DialogInit 250 80 "*Slim*Anim*" 2
		pp_Integer 0 100 8 100 16 "Frame*#*" 1 nbframe		
		pp_Cycle 1 100 28 100 16 "Preview*Size" 1 "96x96|144x144|192x192" Preview
	pp_Dialog
	rc=result
	if rc=0 then DO
		EXIT
	END		

	pp_GetDialog 0
	nbframe=result
	IF nbframe<2 then DO
		pp_Warn 'Not*enough*frame.'		
  	EXIT
	END
	IF nbframe>999 then DO
		nbframe=999
	END

	pp_GetDialog 1
	Preview=result	
				
	pp_MakeAnim nbframe preview
	
	radius=50

	do i=1 to nbframe
		pp_SetJiffies i 2
		do z=0 to width by 50
			do zz=0 to height by 50
				Dx=random(0,5,time('S'))
				Dy=random(0,5,time('S'))
				a=random(0,5,time('S'))
				if a>2 then
					do
						Dx=Dx*-1
					end
				a=random(0,5,time('S'))
				if a>2 then
					do
						Dy=Dy*-1
					end				
				pp_Warp z zz radius Dx Dy
			end
		end
		pp_NextFrame
	end

	pp_PlayAnim 1

	EXIT

