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.
- type HPrim u = H (PrimElement u)
- type Point2T u = Point2 u -> Point2 u
- type DPoint2T = Point2T Double
- newtype DrawingObject a = DrawingObject {
- getDrawingObject :: DrawingContext -> a
- type LocDrawingObject u a = Point2 u -> DrawingObject a
- type DLocDrawingObject a = LocDrawingObject Double a
- liftDrawingObject :: a -> DrawingObject a
- type Graphic u = DrawingObject (HPrim u)
- type DGraphic = Graphic Double
- appendGraphic :: Graphic u -> Graphic u -> Graphic u
- gcat :: Graphic u -> [Graphic u] -> Graphic u
- asksObj :: (DrawingContext -> a) -> DrawingObject a
- localCtxObj :: (DrawingContext -> DrawingContext) -> DrawingObject a -> DrawingObject a
- runGraphic :: DrawingContext -> Graphic u -> HPrim u
- type LocGraphic u = Point2 u -> Graphic u
- type DLocGraphic = LocGraphic Double
- appendAt :: LocGraphic u -> LocGraphic u -> LocGraphic u
- type Image u a = DrawingObject (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 :: DrawingObject a -> Graphic u -> Image u a
- intoLocImage :: LocDrawingObject u a -> LocGraphic u -> LocImage u a
- type ConnDrawingObject u a = Point2 u -> Point2 u -> DrawingObject a
- type DConnDrawingObject a = ConnDrawingObject 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 :: ConnDrawingObject u a -> ConnGraphic u -> ConnImage u a
Documentation
type HPrim u = H (PrimElement u)Source
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.
newtype DrawingObject a Source
type LocDrawingObject u a = Point2 u -> DrawingObject aSource
type DLocDrawingObject a = LocDrawingObject Double aSource
liftDrawingObject :: a -> DrawingObject aSource
type Graphic u = DrawingObject (HPrim u)Source
appendGraphic :: Graphic u -> Graphic u -> Graphic uSource
asksObj :: (DrawingContext -> a) -> DrawingObject aSource
localCtxObj :: (DrawingContext -> DrawingContext) -> DrawingObject a -> DrawingObject aSource
runGraphic :: DrawingContext -> Graphic u -> HPrim 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
appendAt :: 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 = DrawingObject (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
intoImage :: DrawingObject a -> Graphic u -> Image u aSource
intoLocImage :: LocDrawingObject u a -> LocGraphic u -> LocImage u aSource
type ConnDrawingObject u a = Point2 u -> Point2 u -> DrawingObject aSource
type DConnDrawingObject a = ConnDrawingObject 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 :: ConnDrawingObject u a -> ConnGraphic u -> ConnImage u aSource