    	SUBROUTINE IFPOLY( NS, XOP, YOP, RAD1, RAD2, ANGLE )
C
C  PROGRAMMER: R.S. ZHOU		MARCH-1986
C
C	THIS ROUTINE DRAWS A POLYGON.
C
C	NS --------- NUMBER OF SIDES/EDGES.
C	XOP -------- X-COORDINATE OF THE CENTER IN INCHES.
C	YOP -------- Y-COORDINATE OF THE CENTER IN INCHES.
C	RAD1 ------- DIAMETER OF POLYGON IN INCHES.
C	RAD2 ------- BORDER WIDTH (INWARD) IN INCHES.
C	ANGLE ------ ROTATION ANGLE OF OBJECT IN DEGREES FROM X-AXIS.
C
     	INCLUDE 'TEKLIB.CBS'

     	IF( ABS(RAD1).LT.0.05 ) RETURN
     	IWD = IDW
     	IF( ITM.EQ.1 ) GOTO 888
C
C  INITIALIZE...
C
     	IDW = 0
     	NSD = NS
     	IF( NSD.LT.3 ) NSD = 3
     	XPS = XOP
     	YPS = YOP
     	RAD = 0.5*ABS(RAD1)
     	WID = ABS(RAD2)
     	IF( WID.GE.RAD ) WID = 0.0
     	ANG = AMOD( ANGLE, 360.0 )
C
C  MOVE ORIGIN TO (XPS,YPS) ...
C
     	CALL IFPLOT( XPS, YPS, -9 )
C
C  SET ROTATION IF AT ALL...
C
     	IF( ANG.NE.0.0 ) THEN
     	    ANGX = XANG
     	    ANGY = YANG
     	    CALL IFROTA( ANG+XANG, ANG+YANG )
     	ENDIF
C
C  START THE DRAWING...
C
111	CALL IFPLOT( 0.0, RAD, 3 )
     	ANGC = 360.0/NSD
     	DO  I = 1, NSD
     	    XPS = RAD*COS((I*ANGC+90.0)*D2R)
     	    YPS = RAD*SIN((I*ANGC+90.0)*D2R)
     	    CALL IFPLOT( XPS, YPS, 2 )
     	ENDDO
     	IF( WID.EQ.0.0 ) GOTO 222
     	RAD = RAD - WID/COS(0.5*ANGC*D2R)
     	WID = 0.0
     	GOTO 111
C
C  RESTORE...
C
222	IF( ANG.NE.0.0 ) CALL IFROTA( ANGX, ANGY )
     	CALL IFPLOT( -XOP, -YOP, -9 )

888	IF( IWD.NE.0 ) THEN
     	    IF( NPPS.GT.0 ) CALL IFPLOT_DUMP
     	    WRITE(IDF,1000) NS, RAD1,RAD2, XOP,YOP,ANGLE
     	ENDIF
1000	FORMAT('POLY:',I3,5F8.3)
     	IDW = IWD

999	RETURN
    	END
