A Picture-with-implicit-context object.
This is the corresponding type to Picture in the Wumpus-Core.
Note - many of the composition functions are in
destructor form. As Wumpus cannot make a Picture from an
empty list of Pictures, destructor form decomposes the
list into the
rest as arguments in the function
signature, rather than take a possibly empty list and have to
throw an error.
TODO - PosImage no longer supports composition operators, so better names are up for grabs...
- data CtxPicture
- runCtxPicture :: DrawingContext -> CtxPicture -> Maybe Picture
- runCtxPictureU :: DrawingContext -> CtxPicture -> Picture
- drawTracing :: TraceDrawing u a -> CtxPicture
- udrawTracing :: u -> TraceDrawing u a -> CtxPicture
- mapCtxPicture :: (Picture -> Picture) -> CtxPicture -> CtxPicture
- uniteCenter :: CtxPicture -> CtxPicture -> CtxPicture
- centeredAt :: CtxPicture -> DPoint2 -> CtxPicture
A Contextual Picture.
CtxPicture = DrawingContext -> Maybe Picture
This type corresponds to the
Picture type in Wumpus-Core, but
it is embedded with a
DrawingContext (for font properties,
fill colour etc.). The DrawingContext is embedded so that font
metrics - loaded in
IO can be passed into the pure world of
Internally a context picture is a function from
(Maybe Picture). The
that it is possible to construct empty Pictures, even though
Wumpus-Core cannot render them. Just as the DrawingContext
pushes font-metrics from the IO to the pure world, the Maybe
lifts the problem of unrenderable Pictures into the API where
client code must deal with it explicitly.
(In practice, it is very unlikely a program will create empty
runCtxPictureU can be used without worry).
Note - pictures are fixed to the unit
PostScript points). Pictures are intentionally unsophisticated,
any fine grained control of units should be delegated to the
elements that build the picture (Graphics, LocGraphics, etc.).
a `oplus` b
Place 'drawing' a over b. The idea of
drawing_ctx * ctx_picture -> Maybe Picture
The resulting Picture may be empty. Wumpus-Core cannot generate empty pictures as they have no bounding box, so the result is wrapped within a Maybe. This delegates reponsibility for handling empty pictures to client code.
b so its center is at the same center as
b is drawn over underneath in the zorder.
a `cxpUniteCenter` b