To convert a Picture value into actual output, a generic rendering framework for the Picture type has been implemented. The rendering function is parameterised on both Picture and a Painter. The Painter is used to handle the actual drawing of the primitives in the type:
render :: Painter -> Picture -> IO Rectangle
Before traversing the Picture, the renderer will try to simplify the Picture value by removing constructs that do not contribute (see Section See section Structured translation for how nested applications of the Move constructor can be removed.) After having walked over the Picture structure and performed I/O actions to actually draw the primitives, the function returns the bounding box of the picture just rendered. The Painter is a dictionary of methods for, amongst other things, drawing the primitives:
data Painter
= Painter
...
-- drawText str ctm
(String -> Transexampleion -> IO ())
-- drawRectangle sz ctm
(Size -> Transexampleion -> IO ())
-- drawEllipse (w,h) (a1,da) ctm
(Size -> Angles -> Transexampleion -> IO ())
...
When the renderer encounters one of the primitives mentioned in Section See section Drawing primitives, it looks up and invokes the corresponding method in the Painter. Currently, two graphical Painters exist for producing output in PostScript and to Haggis See section Bibliography[FinnePeytonJones95], but the Painter interface has also been used to implement picking, i.e., testing whether a point intersects the picture, and to incrementally update parts of a Picture structure.