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

Stability | highly unstable |

Maintainer | Stephen Tetley <stephen.tetley@gmail.com> |

Safe Haskell | Safe-Infered |

Common core for shapes

- data Shape t u
- type DShape t = Shape t Double
- shapeMap :: InterpretUnit u => (t u -> t' u) -> Shape t u -> Shape t' u
- makeShape :: InterpretUnit u => LocThetaQuery u (t u) -> LocThetaQuery u (AbsPath u) -> Shape t u
- strokedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)
- dblStrokedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)
- filledShape :: InterpretUnit u => Shape t u -> LocImage u (t u)
- borderedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)
- rstrokedShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)
- rfilledShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)
- rborderedShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)
- roundCornerShapePath :: (Real u, Floating u, InterpretUnit u, Tolerance u) => u -> [Point2 u] -> Query u (AbsPath u)
- updatePathAngle :: InterpretUnit u => (Radian -> Radian) -> Shape t u -> Shape t u
- setDecoration :: LocThetaGraphic u -> Shape t u -> Shape t u
- data ShapeCTM u
- makeShapeCTM :: Point2 u -> Radian -> ShapeCTM u
- ctmCenter :: ShapeCTM u -> Point2 u
- ctmAngle :: ShapeCTM u -> Radian
- ctmLocale :: ShapeCTM u -> (Point2 u, Radian)
- projectFromCtr :: (Real u, Floating u) => Vec2 u -> ShapeCTM u -> Anchor u

# Documentation

Shape is a record of three *LocTheta* functions -
functions *from Point and Angle to answer*.

The `shape_path_fun`

returns a path. When the Shape is drawn,
the rendering function (`strokedShape`

, etc.) uses the path for
drawing and returns the polymorphic answer `a`

of the
`shape_ans_fun`

. Lastly the `shape_decoration`

function can
instantiated to add decoration (e.g. text) to the Shape as it
is rendered.

The `a`

of the `shape_ans_fun`

represents some concrete shape
object (e.g. a Rectangle, Triangle etc.). Crucial for shape
objects is that they support Anchors - this allows connectors
to address specific locations on the Shape border so
"node and link" diagrams can be made easily.

shapeMap :: InterpretUnit u => (t u -> t' u) -> Shape t u -> Shape t' uSource

makeShape :: InterpretUnit u => LocThetaQuery u (t u) -> LocThetaQuery u (AbsPath u) -> Shape t uSource

strokedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)Source

dblStrokedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)Source

Note - this is simplistic double stroking - draw a background line with triple thickness and draw a white line on top.

I think this is what TikZ does, but it works better for TikZ where the extra thickness seems to be accounted for by the anchors. For Wumpus, arrows cut into the outside black line.

Probably Wumpus should calculate two paths instead.

filledShape :: InterpretUnit u => Shape t u -> LocImage u (t u)Source

borderedShape :: InterpretUnit u => Shape t u -> LocImage u (t u)Source

rstrokedShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)Source

rfilledShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)Source

rborderedShape :: InterpretUnit u => Shape t u -> LocThetaImage u (t u)Source

roundCornerShapePath :: (Real u, Floating u, InterpretUnit u, Tolerance u) => u -> [Point2 u] -> Query u (AbsPath u)Source

Draw the shape path with round corners.

updatePathAngle :: InterpretUnit u => (Radian -> Radian) -> Shape t u -> Shape t uSource

The path angle can be modified. This allows *inverse*
versions of shapes (e.g. InvTriangle) to be made by
wrapping a base Shape but rotating the path prior to drawing
it.

Only the Path needs rotating, the decoration takes the original angle. The anchors are typically implemented by rotating the correspoding anchor of the wrapped Shape about its center.

setDecoration :: LocThetaGraphic u -> Shape t u -> Shape t uSource

makeShapeCTM :: Point2 u -> Radian -> ShapeCTM uSource