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.
- data GenTraceDrawing st u a
- type TraceDrawing u a = GenTraceDrawing () u a
- type DTraceDrawing a = TraceDrawing Double a
- runTraceDrawing :: TraceDrawing u a -> DrawingContext -> (a, HPrim u)
- execTraceDrawing :: TraceDrawing u a -> DrawingContext -> HPrim u
- evalTraceDrawing :: TraceDrawing u a -> DrawingContext -> a
- runGenTraceDrawing :: GenTraceDrawing st u a -> DrawingContext -> st -> (a, st, HPrim u)
- liftToPictureU :: HPrim u -> Picture
- liftToPictureMb :: HPrim u -> Maybe Picture
- mbPictureU :: Maybe Picture -> Picture
- trace :: HPrim u -> GenTraceDrawing st u ()
- fontDelta :: GenTraceDrawing st u a -> GenTraceDrawing st u a
- evalQuery :: DrawingCtxM m => Query u a -> m a
- draw :: Image u a -> GenTraceDrawing st u ()
- drawi :: Image u a -> GenTraceDrawing st u a
- drawl :: InterpretUnit u => Anchor u -> LocImage u a -> GenTraceDrawing st u ()
- drawli :: InterpretUnit u => Anchor u -> LocImage u a -> GenTraceDrawing st u a
- drawc :: InterpretUnit u => Anchor u -> Anchor u -> ConnectorImage u a -> GenTraceDrawing st u ()
- drawci :: InterpretUnit u => Anchor u -> Anchor u -> ConnectorImage u a -> GenTraceDrawing st u a
- node :: (Fractional u, InterpretUnit u) => (Int, Int) -> LocImage u a -> GenTraceDrawing st u ()
- nodei :: (Fractional u, InterpretUnit u) => (Int, Int) -> LocImage u a -> GenTraceDrawing st u a
- drawrc :: (Real u, Floating u, InterpretUnit u, CenterAnchor a1, RadialAnchor a1, CenterAnchor a2, RadialAnchor a2, u ~ DUnit a1, u ~ DUnit a2) => a1 -> a2 -> ConnectorImage u a -> GenTraceDrawing st u ()
- drawrci :: (Real u, Floating u, InterpretUnit u, CenterAnchor a1, RadialAnchor a1, CenterAnchor a2, RadialAnchor a2, u ~ DUnit a1, u ~ DUnit a2) => a1 -> a2 -> ConnectorImage u a -> GenTraceDrawing st u a
Collect primitives (writer-like monad)
data GenTraceDrawing st u a Source
Monad (GenTraceDrawing st u) | |
Functor (GenTraceDrawing st u) | |
Applicative (GenTraceDrawing st u) | |
DrawingCtxM (GenTraceDrawing st u) | |
UserStateM (GenTraceDrawing st u) |
type TraceDrawing u a = GenTraceDrawing () u aSource
type DTraceDrawing a = TraceDrawing Double aSource
runTraceDrawing :: TraceDrawing u a -> DrawingContext -> (a, HPrim u)Source
execTraceDrawing :: TraceDrawing u a -> DrawingContext -> HPrim uSource
Run the drawing returning only the output it produces, drop any answer from the monadic computation.
evalTraceDrawing :: TraceDrawing u a -> DrawingContext -> 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).
runGenTraceDrawing :: GenTraceDrawing st u a -> DrawingContext -> st -> (a, st, HPrim u)Source
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.
trace :: HPrim u -> GenTraceDrawing st u ()Source
Primitive operation - cf. tell in Reader monad.
fontDelta :: GenTraceDrawing st u a -> GenTraceDrawing st u aSource
evalQuery :: DrawingCtxM m => Query u a -> m aSource
draw :: Image u a -> GenTraceDrawing st u ()Source
drawi :: Image u a -> GenTraceDrawing st u 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 :: InterpretUnit u => Anchor u -> LocImage u a -> GenTraceDrawing st u ()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 :: InterpretUnit u => Anchor u -> LocImage u a -> GenTraceDrawing st u 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 :: InterpretUnit u => Anchor u -> Anchor u -> ConnectorImage u a -> GenTraceDrawing st u ()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 :: InterpretUnit u => Anchor u -> Anchor u -> ConnectorImage u a -> GenTraceDrawing st u 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, InterpretUnit u) => (Int, Int) -> LocImage u a -> GenTraceDrawing st u ()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, InterpretUnit u) => (Int, Int) -> LocImage u a -> GenTraceDrawing st u 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, InterpretUnit u, CenterAnchor a1, RadialAnchor a1, CenterAnchor a2, RadialAnchor a2, u ~ DUnit a1, u ~ DUnit a2) => a1 -> a2 -> ConnectorImage u a -> GenTraceDrawing st u ()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, InterpretUnit u, CenterAnchor a1, RadialAnchor a1, CenterAnchor a2, RadialAnchor a2, u ~ DUnit a1, u ~ DUnit a2) => a1 -> a2 -> ConnectorImage u a -> GenTraceDrawing st u aSource
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.