      subroutine newpen (ipen)
c
c Set the line, text , and perimeter color.
c
c The colors are:
c 		1	black
c		2	red
c		3	yellow
c		4	green
c		5	cyan
c		6	blue
c		7	magenta
c		8	white
c 
c James Blake
c @(#)newpen.f	1.1  4/3/89 
c
      include 'device_type.h'
      integer usepen
      integer savpen
      save	savpen
      data	savpen /1/
      common/local_color/gray_level
c
      if (color_ws .or. mono_ws) then
         npen = ipen - 1
         if (color_ws) then
              if( npen .lt. 0 .or. npen .gt. 7 ) npen = 0
         elseif(mono_ws) then
              if (npen.eq.7) then
                   npen = 0
              else
                   npen = 1
              endif
         endif
         call cflncolor   (npen)
         call cftextcolor (npen)
         call cfperimcolor(npen)
      elseif (PostScript) then
C
C  Simulated by changing line width for PostScript printers
C
         if (gray_level .ne. 0.0) then
            call plsout ("0.0 setgray\n")
         endif
         npen = max (ipen, 1)
         if (npen .ne. savpen) then
C
C	Want pen width to be odd number of pixels wide
C
            usepen = ((npen -1) * 2) + 1
            call pliout (usepen)
            call plsout (" W\n")
            savpen = npen
         end if
      endif
      return
      end
