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

Stability | highly unstable |

Maintainer | stephen.tetley@gmail.com |

Base types for Drawing Objects, Graphics / Images (a Graphic that also returns an answer), etc.

** WARNING ** - some names are expected to change
particularly the naming of the *append* and *concat* functions.

- data HPrim u
- hprimToList :: HPrim u -> [PrimElement u]
- singleH :: PrimElement u -> HPrim u
- type Point2F u = Point2 u -> Point2 u
- type DPoint2F = Point2F Double
- data DrawingF a
- type LocDrawingF u a = Point2 u -> DrawingF a
- type DLocDrawingF a = LocDrawingF Double a
- runDF :: DrawingContext -> DrawingF a -> a
- pureDF :: a -> DrawingF a
- askDF :: DrawingF DrawingContext
- asksDF :: (DrawingContext -> a) -> DrawingF a
- localDF :: (DrawingContext -> DrawingContext) -> DrawingF a -> DrawingF a
- type Graphic u = DrawingF (HPrim u)
- type DGraphic = Graphic Double
- runGraphic :: DrawingContext -> Graphic u -> HPrim u
- xlinkGraphic :: XLink -> Graphic u -> Graphic u
- type LocGraphic u = Point2 u -> Graphic u
- type DLocGraphic = LocGraphic Double
- localLG :: (DrawingContext -> DrawingContext) -> LocGraphic u -> LocGraphic u
- lgappend :: LocGraphic u -> LocGraphic u -> LocGraphic u
- type Image u a = DrawingF (a, HPrim u)
- type DImage a = Image Double a
- type LocImage u a = Point2 u -> Image u a
- type DLocImage a = LocImage Double a
- runImage :: DrawingContext -> Image u a -> (a, HPrim u)
- intoImage :: DrawingF a -> Graphic u -> Image u a
- intoLocImage :: LocDrawingF u a -> LocGraphic u -> LocImage u a
- xlinkImage :: XLink -> Image u a -> Image u a
- type ConnDrawingF u a = Point2 u -> Point2 u -> DrawingF a
- type DConnDrawingF a = ConnDrawingF Double a
- type ConnGraphic u = Point2 u -> Point2 u -> Graphic u
- type DConnGraphic = ConnGraphic Double
- type ConnImage u a = Point2 u -> Point2 u -> Image u a
- type DConnImage a = ConnImage Double a
- intoConnImage :: ConnDrawingF u a -> ConnGraphic u -> ConnImage u a

# Documentation

Graphics objects, even simple ones (line, arrow, dot) might
need more than one primitive (path or text label) for their
construction. Hence, the primary representation that all the
others are built upon must support *concatenation* of
primitives.

Wumpus-Core has a type Picture - made from one or more Primitives - but Pictures include support for affine frames. For drawing many simple graphics (dots, connector lines...) that do not need individual affine transformations this is a penalty. A list of Primitives is therefore more suitable representation, and a Hughes list which supports efficient concatenation is wise.

hprimToList :: HPrim u -> [PrimElement u]Source

singleH :: PrimElement u -> HPrim uSource

Drawings in Wumpus-Basic have an implicit *graphics state*
the `DrawingContext`

, the most primitive building block is
a function from the DrawingContext to some polymorphic answer.

This functional type is represented concretely as `DrawingF`

.

DrawingF :: DrawingContext -> a

type LocDrawingF u a = Point2 u -> DrawingF aSource

type DLocDrawingF a = LocDrawingF Double aSource

runDF :: DrawingContext -> DrawingF a -> aSource

Run a *Drawing Function* with the supplied *Drawing Context*.

pureDF :: a -> DrawingF aSource

Wrap a value into a DrawingF.

Note the value is *pure* it does depend on the DrawingContext
(it is *context free*).

asksDF :: (DrawingContext -> a) -> DrawingF aSource

localDF :: (DrawingContext -> DrawingContext) -> DrawingF a -> DrawingF aSource

runGraphic :: DrawingContext -> Graphic u -> HPrim uSource

xlinkGraphic :: XLink -> Graphic u -> Graphic uSource

type LocGraphic u = Point2 u -> Graphic uSource

Commonly graphics take a start point as well as a drawing context.

Here they are called a LocGraphic - graphic with a (starting) location.

type DLocGraphic = LocGraphic DoubleSource

localLG :: (DrawingContext -> DrawingContext) -> LocGraphic u -> LocGraphic uSource

lgappend :: LocGraphic u -> LocGraphic u -> LocGraphic uSource

Composition operator for LocGraphic - both LocGraphics are drawn at the same origin and the results concatenated.

type Image u a = DrawingF (a, HPrim u)Source

Images return a value as well as drawing. A *node* is a
typical example - nodes are drawing but the also support
taking anchor points.

runImage :: DrawingContext -> Image u a -> (a, HPrim u)Source

intoLocImage :: LocDrawingF u a -> LocGraphic u -> LocImage u aSource

xlinkImage :: XLink -> Image u a -> Image u aSource

type ConnDrawingF u a = Point2 u -> Point2 u -> DrawingF aSource

type DConnDrawingF a = ConnDrawingF Double aSource

type ConnGraphic u = Point2 u -> Point2 u -> Graphic uSource

ConnGraphic is a connector drawn between two points contructing a Graphic.

type DConnGraphic = ConnGraphic DoubleSource

type ConnImage u a = Point2 u -> Point2 u -> Image u aSource

ConImage is a connector drawn between two points constructing an Image.

type DConnImage a = ConnImage Double aSource

intoConnImage :: ConnDrawingF u a -> ConnGraphic u -> ConnImage u aSource