/* Dissolve ZigZag
110
*/

	call addlib("rexxmathlib.library", 5, -30, 0)

	options results

	parse ARG Port Opt1 Opt2 Opt3 s0 t0 s1 t1 b
	
	ADDRESS value Port

	pp_GetWidth
	w=result
	pp_GetHeight
	h=result
	pp_GetDepth
	D=result

	pp_GetCurrentBuffer
	CBf=result
	pp_GetCurrentBrush
	CB=result

	pp_FindEmptyBrush
	Brush=result
	if Brush=-1 then DO
		pp_Warn "can't*find*empty|Brush."
		EXIT		
	END
	pp_SetBrush Brush		

	pp_FindEmptyBuffer
	Bf=result
	if Bf=-1 then DO
		pp_Warn "can't*find*empty|Buffer."
		EXIT		
	END
	pp_SetBuffer Bf

	pp_New w h 24
	pp_SpareOnOff

	/* Draw your Mask */
		pp_ClearRange 0
		IF Opt2=0 then DO
			pp_setRange 0 0 0 0 0
			pp_setRange 0 4 255 255 255
			pp_setRange 0 8 0 0 0
			pp_setRange 0 12 255 255 255
			pp_setRange 0 16 0 0 0
			pp_setRange 0 19 255 255 255
			pp_Gradient 0 2 w/2 h/2
		END
		IF Opt2=1 then DO
			pp_setRange 0 4 0 0 0
			pp_setRange 0 0 255 255 255
			pp_setRange 0 12 0 0 0
			pp_setRange 0 8 255 255 255
			pp_setRange 0 19 0 0 0
			pp_setRange 0 16 255 255 255
			pp_Gradient 0 2 w/2 h/2
		END

		pp_EffectOn
		pp_ComposeReqOff
		pp_BoxF 0 0 w-1 h-1
		pp_ComposeReqOn
		pp_EffectOff

	/*	End	*/
	
	pp_SparetoStencil
	pp_SSave "ram:DisSten"
	pp_ClearCurrentBuffer
	pp_SetBuffer CBf

	pp_SLoad "ram:DisSten"
	ADDRESS COMMAND
	'delete >nil: ram:DisSten'
	ADDRESS value Port

	pp_GotoFrame s1
	pp_PicttoSpare
	pp_GotoFrame s0			
	pp_Pickbrush 0 0 W H 1
	
	step=(s1-s0)
	Step_f=255/Step

	DO i=s0 to s1
		IF t1=1 then DO
			pp_GotoFrame (s1+i-s0)
			pp_PicttoSpare
		END

		pp_GotoFrame i

		IF t0=0 then DO
			pp_plot W/2 H/2
		END

		f=Step_f*(i-s0)
		IF Opt1=0 then DO
			pp_Dissolve f 255			
		END
		ELSE DO
			pp_Dissolve f f
		END
		pp_Refresh
	END

		pp_Gotoframe s0
		pp_FreeBrush
		pp_SetBrush CB

	EXIT
