/* Script Rexx
	AnimPainting for Line*/

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

	options results
  parse ARG Port x1 y1 x2 y2 b
	ADDRESS value Port

	pp_CountFrames
	nb=result
	IF nb<2 then DO
		pp_Warn 'Make*an*Anim*first.'
		EXIT
	END	

  X=x1
  Y=y1

  DX=x2 - x1
  DY=y2 - y1

  If DX < 0 THEN DO
    XC=-1
    DX = -DX
  END
  ELSE
  DO
    XC=1
  END


  If DY < 0 THEN DO
    YC=-1
    DY = -DY
  END
  ELSE
  DO
    YC= 1
  END

	ERROR=0
	i=0

	If DX < DY THEN DO
    L=DY + 1
    DO While i < L
    	pp_Plot X Y
	   	pp_NextFrame
      Y=Y + YC
      Error=Error + DX
      If Error >DY THEN DO
      	X=X + XC
        Error=Error - DY
      END
      i=i + 1
    END
	END
	ELSE
	DO
  	L=DX + 1
    DO While i < L
    	pp_Plot X Y
	   	pp_NextFrame
      X=X + XC
      Error=Error + DY
      If Error > DX THEN DO
      	Y=Y + YC
        Error=Error - DX
      END
      i=i + 1
    END
	END

