1 module Postscript(Output, draw)where 2 import Numbers 3 import Vectors 4 import EdgePlate 5 -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 -- Postscript driver for hiddenline program 7 -- Last update 14 Januari 92 8 9 type Output = String 10 11 draw :: [Edge] -> Output 12 draw ls = iniplot ++ plot ls exiplot 13 where 14 iniplot = "\nerasepage gsave 100 100 translate 0 setlinewidth newpath\n" 15 exiplot = "\nstroke grestore\n" 16 17 plot :: [Edge] -> ShowS 18 plotFrom :: Vector -> [Edge] -> ShowS 19 moveTo,lineTo :: Vector -> ShowS 20 flush :: ShowS 21 22 plot [] = \s->s 23 plot ls@(l:_) = moveTo (s(l)) . plotFrom (s(l)) ls 24 25 plotFrom currentPoint [] = \s->s 26 plotFrom currentPoint (l:ls) 27 | s(l) == currentPoint = lineTo (t(l)) . plotFrom (t(l)) ls 28 | s(l) /= currentPoint = flush . plot (l:ls) 29 moveTo v = shows (x(v)) . showChar ' ' . shows (y(v)) . showString " moveto " 30 lineTo v = shows (x(v)) . showChar ' ' . shows (y(v)) . showString " lineto " 31 flush = showString "\nstroke newpath\n"