wumpus-basic-0.16.0: Basic objects and system code built on Wumpus-Core.

Stabilityhighly unstable
MaintainerStephen Tetley <stephen.tetley@gmail.com>




Anchor points on shapes, bounding boxes, etc.

Anchors are addressable positions, an examplary use is taking anchors on node shapes to get the start and end points for connectors in a network (graph) diagram.

** WARNING ** - The API here needs some thought as to a good balance of the type classes - in a nutshell "are corners better than cardinals". Originally I tried to follow how I understand the TikZ anchors to work, but this is perhaps not ideal for dividing into type-classes.



class CenterAnchor t whereSource

Center of an object.


center :: DUnit t ~ u => t -> Point2 uSource


class ApexAnchor t whereSource

Apex of an object.


apex :: DUnit t ~ u => t -> Point2 uSource

class CardinalAnchor t whereSource

Cardinal (compass) positions on an object.

Note - in TikZ cardinal anchors are not necessarily at the equivalent radial position, for instance reactangle north-east is the top-right corner whether or not this is incident at 45deg.

Wumpus generally follows the TikZ convention.


north :: DUnit t ~ u => t -> Point2 uSource

south :: DUnit t ~ u => t -> Point2 uSource

east :: DUnit t ~ u => t -> Point2 uSource

west :: DUnit t ~ u => t -> Point2 uSource

class CardinalAnchor2 t whereSource

Secondary group of cardinal (compass) positions on an object.

It seems possible that for some objects defining the primary compass points (north, south,...) will be straight-forward whereas defining the secondary compass points may be problematic, hence the compass points are split into two classes.


northeast :: DUnit t ~ u => t -> Point2 uSource

southeast :: DUnit t ~ u => t -> Point2 uSource

southwest :: DUnit t ~ u => t -> Point2 uSource

northwest :: DUnit t ~ u => t -> Point2 uSource

class RadialAnchor t whereSource

Anchor on a border that can be addressed by an angle.

The angle is counter-clockwise from the right-horizontal, i.e. 0 is east.


radialAnchor :: DUnit t ~ u => Radian -> t -> Point2 uSource

class TopCornerAnchor t whereSource

Anchors at the top left and right corners of a shape.

For some shapes (Rectangle) the TikZ convention appears to be have cardinals as the corner anchors, but this doesn't seem to be uniform. Wumpus will need to reconsider anchors at some point...


topLeftCorner :: DUnit t ~ u => t -> Point2 uSource

topRightCorner :: DUnit t ~ u => t -> Point2 uSource

class BottomCornerAnchor t whereSource

Anchors at the bottom left and right corners of a shape.


bottomLeftCorner :: DUnit t ~ u => t -> Point2 uSource

bottomRightCorner :: DUnit t ~ u => t -> Point2 uSource

class SideMidpointAnchor t whereSource

Anchors in the center of a side.

Sides are addressable by index. Following TikZ, side 1 is expected to be the top of the shape. If the shape has an apex instead of a side then side 1 is expected to be the first side left of the apex.

Implementations are also expected to modulo the side number, rather than throw an out-of-bounds error.


sideMidpoint :: DUnit t ~ u => Int -> t -> Point2 uSource

Extended anchor points

projectAnchor :: (Real u, Floating u, u ~ DUnit t, CenterAnchor t) => (t -> Point2 u) -> u -> t -> Point2 uSource

projectAnchor : extract_func * dist * object -> Point

Derive a anchor by projecting a line from the center of an object through the intermediate anchor (produced by the extraction function). The final answer point is located along the projected line at the supplied distance dist.

E.g. take the north of a rectangle and project it 10 units further on:

 projectAnchor north 10 my_rect

If the distance is zero the answer with be whatever point the the extraction function produces.

If the distance is negative the answer will be along the projection line, between the center and the intermediate anchor.

If the distance is positive the anchor will be extend outwards from the intermediate anchor.

radialConnectorPoints :: (Real u, Floating u, CenterAnchor t1, RadialAnchor t1, CenterAnchor t2, RadialAnchor t2, u ~ DUnit t1, DUnit t1 ~ DUnit t2) => t1 -> t2 -> (Point2 u, Point2 u)Source

radialConnectorPoints : object_a * object_b -> (Point_a, Point_b)

Find the radial connectors points for objects a and b along the line joining their centers.