diagrams-lib-1.2.0.1: Embedded domain-specific language for declarative graphics

Diagrams.TwoD.Arrow

Description

Drawing arrows in two dimensions. For a tutorial on drawing arrows using this module, see the diagrams website: http://projects.haskell.org/diagrams/doc/arrow.html.

Synopsis

# Examples

## Example 1

```-- Connecting two diagrams at their origins.

sq = square 2 # showOrigin # lc darkgray # lw ultraThick
ds = (sq # named "left") ||| strutX 3 ||| (sq # named "right")

shaft  = cubicSpline False ( map p2 [(0, 0), (1, 0), (1, 0.2), (2, 0.2)])

example1 = ds # connect' (with & arrowHead .~ dart & arrowTail .~ quill
& arrowShaft .~ shaft
& headLength .~ huge & tailLength .~ veryLarge)

## Example 2

```-- Comparing connect, connectPerim, and arrowAt.

oct  = octagon 1 # lc darkgray # lw ultraThick # showOrigin
dias = oct # named "first" ||| strut 3 ||| oct # named "second"

-- Connect two diagrams and two points on their trails.
ex12 = dias # connect' (with & lengths .~ veryLarge) "first" "second"
# connectPerim' (with & lengths .~ veryLarge)
"first" "second" (15/16 @@ turn) (9/16 @@ turn)

-- Place an arrow at (0,0) the size and direction of (0,1).
ex3 = arrowAt origin unit_Y

example2 = (ex12 <> ex3) # centerXY # pad 1.1```

# Creating arrows

arrowV :: Renderable (Path R2) b => R2 -> Diagram b R2 Source

`arrowV v` creates an arrow with the direction and magnitude of the vector `v` (with its tail at the origin), using default parameters.

arrowV' :: Renderable (Path R2) b => ArrowOpts -> R2 -> Diagram b R2 Source

`arrowV' v` creates an arrow with the direction and magnitude of the vector `v` (with its tail at the origin).

arrowAt :: Renderable (Path R2) b => P2 -> R2 -> Diagram b R2 Source

Create an arrow starting at s with length and direction determined by the vector v.

arrowBetween :: Renderable (Path R2) b => P2 -> P2 -> Diagram b R2 Source

`arrowBetween s e` creates an arrow pointing from `s` to `e` with default parameters.

arrowBetween' :: Renderable (Path R2) b => ArrowOpts -> P2 -> P2 -> Diagram b R2 Source

`arrowBetween' opts s e` creates an arrow pointing from `s` to `e` using the given options. In particular, it scales and rotates `arrowShaft` to go between `s` and `e`, taking head, tail, and gaps into account.

connect :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Diagram b R2 -> Diagram b R2 Source

Connect two diagrams with a straight arrow.

connect' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2 Source

Connect two diagrams with an arbitrary arrow.

connectPerim :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Angle -> Angle -> Diagram b R2 -> Diagram b R2 Source

Connect two diagrams at point on the perimeter of the diagrams, choosen by angle.

connectPerim' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Angle -> Angle -> Diagram b R2 -> Diagram b R2 Source

connectOutside :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Diagram b R2 -> Diagram b R2 Source

Draw an arrow from diagram named "n1" to diagram named "n2". The arrow lies on the line between the centres of the diagrams, but is drawn so that it stops at the boundaries of the diagrams, using traces to find the intersection points.

connectOutside' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2 Source

arrow :: Renderable (Path R2) b => Double -> Diagram b R2 Source

`arrow len` creates an arrow of length `len` with default parameters, starting at the origin and ending at the point `(len,0)`.

arrow' :: Renderable (Path R2) b => ArrowOpts -> Double -> Diagram b R2 Source

`arrow' opts len` creates an arrow of length `len` using the given options, starting at the origin and ending at the point `(len,0)`. In particular, it scales the given `arrowShaft` so that the entire arrow has length `len`.

# Options

data ArrowOpts Source

Constructors

 ArrowOpts Fields_arrowHead :: ArrowHT _arrowTail :: ArrowHT _arrowShaft :: Trail R2 _headGap :: Measure R2 _tailGap :: Measure R2 _headStyle :: Style R2 _headLength :: Measure R2 _tailStyle :: Style R2 _tailLength :: Measure R2 _shaftStyle :: Style R2

Instances

 Default ArrowOpts

A shape to place at the head of the arrow.

A shape to place at the tail of the arrow.

The trail to use for the arrow shaft.

Distance to leave between the head and the target point.

Distance to leave between the starting point and the tail.

Set both the `headGap` and `tailGap` simultaneously.

Same as gaps, provided for backward compatiiblity.

A lens for setting or modifying the texture of an arrowhead. For example, one may write `... (with & headTexture .~ grad)` to get an arrow with a head filled with a gradient, assuming grad has been defined. Or `... (with & headTexture .~ solid blue` to set the head color to blue. For more general control over the style of arrowheads, see `headStyle`.

Style to apply to the head. `headStyle` is modified by using the lens combinator `%~` to change the current style. For example, to change an opaque black arrowhead to translucent orange: `(with & headStyle %~ fc orange . opacity 0.75)`.

The length from the start of the joint to the tip of the head.

A lens for setting or modifying the texture of an arrow tail.

Style to apply to the tail. See `headStyle`.

The length of the tail plus its joint.

Set both the `headLength` and `tailLength` simultaneously.

A lens for setting or modifying the texture of an arrow shaft.

Style to apply to the shaft. See `headStyle`.

Straight line arrow shaft.