Go to the first, previous, next, last section, table of contents.

Procedural drawing abstraction

To create a DrawArea component you only need to specify the size of the drawing area to initially use:


drawArea :: Size -> Component (DrawArea, DisplayHandle)

main =
 wopen [] (drawArea (200,200)) >>= \ (dArea,_) ->
 drawProc dArea >>
 return ()

the creator function drawArea returns a handle of type DrawArea through which the drawing commands on the created area is communicated. As an example, here is a function that draws a asteroid field: (The code for setting up and performing the drawing is somewhat long, @xref{Rocks} for complete listing.)


drawProc :: DrawArea -> IO ()
drawProc da = simRocks da 100

DrawArea example


Go to the first, previous, next, last section, table of contents.