Portability | GHC |
---|---|

Stability | unstable |

Maintainer | stephen.tetley@gmail.com |

Drawing with *trace* - a Writer like monad collecting
intermediate graphics - and *drawing context* - a reader monad
of attributes - font_face, fill_colour etc.

- class TraceM m where
- data TraceDrawing u a
- type DTraceDrawing a = TraceDrawing Double a
- data TraceDrawingT u m a
- type DTraceDrawingT m a = TraceDrawingT Double m a
- runTraceDrawing :: DrawingContext -> TraceDrawing u a -> (a, HPrim u)
- execTraceDrawing :: DrawingContext -> TraceDrawing u a -> HPrim u
- evalTraceDrawing :: DrawingContext -> TraceDrawing u a -> a
- runTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m (a, HPrim u)
- execTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m (HPrim u)
- evalTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m a
- liftToPictureU :: HPrim u -> Picture
- liftToPictureMb :: HPrim u -> Maybe Picture
- mbPictureU :: Maybe Picture -> Picture
- evalQuery :: DrawingCtxM m => Query u a -> m a
- draw :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Image u a -> m ()
- drawi :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Image u a -> m a
- drawl :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> LocImage u a -> m ()
- drawli :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> LocImage u a -> m a
- drawc :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> Anchor u -> ConnectorImage u a -> m ()
- drawci :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> Anchor u -> ConnectorImage u a -> m a
- node :: (Fractional u, TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => (Int, Int) -> LocImage u a -> m ()
- nodei :: (Fractional u, TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => (Int, Int) -> LocImage u a -> m a
- drawrc :: (Real u, Floating u, DrawingCtxM m, TraceM m, CenterAnchor a, RadialAnchor a, CenterAnchor b, RadialAnchor b, u ~ MonUnit (m ()), u ~ DUnit a, u ~ DUnit b) => a -> b -> ConnectorImage u ans -> m ()
- drawrci :: (Real u, Floating u, DrawingCtxM m, TraceM m, CenterAnchor a, RadialAnchor a, CenterAnchor b, RadialAnchor b, u ~ MonUnit (m ()), u ~ DUnit a, u ~ DUnit b) => a -> b -> ConnectorImage u ans -> m ans

# Collect primitives (writer monad)

Collect elementary graphics as part of a larger drawing.

TraceM works much like a writer monad.

TraceM (TraceDrawing u) | |

Monad m => TraceM (TraceDrawingT u m) |

data TraceDrawing u a Source

Monad (TraceDrawing u) | |

Functor (TraceDrawing u) | |

Applicative (TraceDrawing u) | |

DrawingCtxM (TraceDrawing u) | |

TraceM (TraceDrawing u) |

type DTraceDrawing a = TraceDrawing Double aSource

data TraceDrawingT u m a Source

Monad m => Monad (TraceDrawingT u m) | |

Monad m => Functor (TraceDrawingT u m) | |

Monad m => Applicative (TraceDrawingT u m) | |

Monad m => DrawingCtxM (TraceDrawingT u m) | |

Monad m => TraceM (TraceDrawingT u m) |

type DTraceDrawingT m a = TraceDrawingT Double m aSource

runTraceDrawing :: DrawingContext -> TraceDrawing u a -> (a, HPrim u)Source

execTraceDrawing :: DrawingContext -> TraceDrawing u a -> HPrim uSource

Run the drawing returning only the output it produces, drop any answer from the monadic computation.

evalTraceDrawing :: DrawingContext -> TraceDrawing u a -> aSource

Run the drawing ignoring the output it produces, return the answer from the monadic computation.

Note - this useful for testing, generally one would want the opposite behaviour (return the drawing, ignore than the answer).

runTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m (a, HPrim u)Source

execTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m (HPrim u)Source

evalTraceDrawingT :: Monad m => DrawingContext -> TraceDrawingT u m a -> m aSource

liftToPictureU :: HPrim u -> PictureSource

*Unsafe* promotion of `HPrim`

to `Picture`

.

If the HPrim is empty, a run-time error is thrown.

liftToPictureMb :: HPrim u -> Maybe PictureSource

*Safe* promotion of `HPrim`

to `(Maybe Picture)`

.

If the HPrim is empty, then `Nothing`

is returned.

mbPictureU :: Maybe Picture -> PictureSource

*Unsafe* promotion of `(Maybe Picture)`

to `Picture`

.

This is equivalent to:

fromMaybe (error "empty") $ pic

This function is solely a convenience, using it saves one import and a few characters.

If the supplied value is `Nothing`

a run-time error is thrown.

evalQuery :: DrawingCtxM m => Query u a -> m aSource

drawi :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Image u a -> m aSource

Draw an Image taking the drawing style from the
*drawing context*.

The graphic representation of the Image is drawn in the Trace monad, and the result is returned.

drawl :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> LocImage u a -> m ()Source

Draw a LocImage at the supplied Anchor taking the drawing
style from the *drawing context*.

This function is the *forgetful* version of `drawli`

.
Commonly, it is used to draw `LocGraphic`

objects which
have no *answer*.

drawli :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> LocImage u a -> m aSource

Draw a LocImage at the supplied Point taking the drawing
style from the *drawing context*.

The graphic representation of the Image is drawn in the Trace monad, and the result is returned.

drawc :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> Anchor u -> ConnectorImage u a -> m ()Source

Draw a ConnectorGraphic with the supplied Anchors taking the
drawing style from the *drawing context*.

This function is the *forgetful* version of `drawci`

.
Commonly, it is used to draw `ConnectorGraphic`

objects which
have no *answer*.

drawci :: (TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => Anchor u -> Anchor u -> ConnectorImage u a -> m aSource

Draw a ConnectorImage with the supplied Points taking the
drawing style from the *drawing context*.

The graphic representation of the Image is drawn in the Trace monad, and the result is returned.

node :: (Fractional u, TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => (Int, Int) -> LocImage u a -> m ()Source

Draw the object with the supplied grid coordinate. The
actual position is scaled according to the
`snap_grid_factors`

in the *drawing context*.

This function is the *forgetful* version of `nodei`

.
Commonly, it is used to draw `LocGraphic`

objects which
have no *answer*.

nodei :: (Fractional u, TraceM m, DrawingCtxM m, u ~ MonUnit (m ())) => (Int, Int) -> LocImage u a -> m aSource

Draw the object with the supplied grid coordinate. The
actual position is scaled according to the
`snap_grid_factors`

in the *drawing context*.

drawrc :: (Real u, Floating u, DrawingCtxM m, TraceM m, CenterAnchor a, RadialAnchor a, CenterAnchor b, RadialAnchor b, u ~ MonUnit (m ()), u ~ DUnit a, u ~ DUnit b) => a -> b -> ConnectorImage u ans -> m ()Source

Draw a connector between two objects. The projection of the connector line is drawn on the line from center to center of the objects, the actual start and end points of the drawn line are the radial points on the objects borders that cross the projected line.

This function is the *forgetful* version of `drawrci`

.
Commonly, it is used to draw `LocGraphic`

objects which
have no *answer*.

drawrci :: (Real u, Floating u, DrawingCtxM m, TraceM m, CenterAnchor a, RadialAnchor a, CenterAnchor b, RadialAnchor b, u ~ MonUnit (m ()), u ~ DUnit a, u ~ DUnit b) => a -> b -> ConnectorImage u ans -> m ansSource

Draw a connector between two objects. The projection of the connector line is drawn on the line from center to center of the objects, the actual start and end points of the drawn line are the radial points on the objects borders that cross the projected line.