Sunday, November 14, 2010

wumpus-basic

Copperbox revision 1870.

Some more work on font metrics integration.

The problem with IO is a bit more drastic than I previously realized, previously I made pictures like this:

dctx :: DrawingContext
dctx = fontface courier_bold $ standardContext 24

pic1 :: DPicture
pic1 = liftToPictureU $ execTraceDrawing dctx $ do
    draw $ textlineMulti ["hello", "world"] `at` zeroPt

However, to accommodate the font loader I'll no longer be able to create a DrawingContext statically as a top level binding, I'll have to acquire BaseGlyphMetrics in IO then make a context like this:

makeDctx :: BaseGlyphMetrics Double -> DrawingContext
makeDctx base_metrics =
    fontface courier_bold $ standardContext 24 base_metrics

This will also mandate a change to pic1, it will have to become a functional type taking the runtime drawing context rather than just a picture:

pic1 :: DrawingContext -> DPicture
pic1 dctx = liftToPictureU $ execTraceDrawing dctx $ do
     draw $ textlineMulti ["hello", "world"] `at` zeroPt

This probably means I'll end up changing the (Wumpus-basic) Picture type so it is a function from DrawingContext to (Wumpus-core) Picture rather than just a Picture. The thought of this does make me worry about efficiency and that Wumpus is getting too higher-order, though.

Blog Archive

About Me

My photo
Disambiguating biog as there are a few Stephen Tetley's in the world. I'm neither a cage fighter or yachtsman. I studied Fine Art in the nineties (foundation Bradford 1992, degree Cheltenham 1992 - 95) then Computing part-time at Leeds Met graduating in 2003. I'm the Stephen Tetley on Haskell Cafe and Stackoverflow.