Maintainer | diagrams-discuss@googlegroups.com |
---|---|
Safe Haskell | None |
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.
- arrowV :: Renderable (Path R2) b => R2 -> Diagram b R2
- arrowV' :: Renderable (Path R2) b => ArrowOpts -> R2 -> Diagram b R2
- arrowAt :: Renderable (Path R2) b => P2 -> R2 -> Diagram b R2
- arrowAt' :: Renderable (Path R2) b => ArrowOpts -> P2 -> R2 -> Diagram b R2
- arrowBetween :: Renderable (Path R2) b => P2 -> P2 -> Diagram b R2
- arrowBetween' :: Renderable (Path R2) b => ArrowOpts -> P2 -> P2 -> Diagram b R2
- connect :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Diagram b R2 -> Diagram b R2
- connect' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2
- connectPerim :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Angle -> Angle -> Diagram b R2 -> Diagram b R2
- connectPerim' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Angle -> Angle -> Diagram b R2 -> Diagram b R2
- connectOutside :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Diagram b R2 -> Diagram b R2
- connectOutside' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2
- arrow :: Renderable (Path R2) b => Double -> Diagram b R2
- arrow' :: Renderable (Path R2) b => ArrowOpts -> Double -> Diagram b R2
- data ArrowOpts = ArrowOpts {
- _arrowHead :: ArrowHT
- _arrowTail :: ArrowHT
- _arrowShaft :: Trail R2
- _headSize :: Double
- _tailSize :: Double
- _headGap :: Double
- _tailGap :: Double
- _headStyle :: Style R2
- _tailStyle :: Style R2
- _shaftStyle :: Style R2
- arrowHead :: Lens' ArrowOpts ArrowHT
- arrowTail :: Lens' ArrowOpts ArrowHT
- arrowShaft :: Lens' ArrowOpts (Trail R2)
- headSize :: Lens' ArrowOpts Double
- tailSize :: Lens' ArrowOpts Double
- headGap :: Lens' ArrowOpts Double
- tailGap :: Lens' ArrowOpts Double
- gap :: Traversal' ArrowOpts Double
- headColor :: Color c => Setter' ArrowOpts c
- headStyle :: Lens' ArrowOpts (Style R2)
- tailColor :: Color c => Setter' ArrowOpts c
- tailStyle :: Lens' ArrowOpts (Style R2)
- shaftColor :: Color c => Setter' ArrowOpts c
- shaftStyle :: Lens' ArrowOpts (Style R2)
- straightShaft :: Trail R2
- module Diagrams.TwoD.Arrowheads
Examples
Example 1
-- Connecting two diagrams at their origins. sq = square 2 # showOrigin # lc darkgray # lw 0.07 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 & headSize .~ 0.6 & tailSize .~ 0.5 & arrowTail .~ quill & shaftStyle %~ lw 0.02 & arrowShaft .~ shaft) "left" "right" # pad 1.1
Example 2
-- Comparing connect, connectPerim, and arrowAt. oct = octagon 1 # lc darkgray # lw 0.10 # showOrigin dias = oct # named "first" ||| strut 3 ||| oct # named "second" -- Connect two diagrams and two points on their trails. ex12 = dias # connect "first" "second" # connectPerim "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 R2Source
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 R2Source
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 R2Source
Create an arrow starting at s with length and direction determined by the vector v.
arrowBetween :: Renderable (Path R2) b => P2 -> P2 -> Diagram b R2Source
arrowBetween s e
creates an arrow pointing from s
to e
with default parameters.
arrowBetween' :: Renderable (Path R2) b => ArrowOpts -> P2 -> P2 -> Diagram b R2Source
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 R2Source
Connect two diagrams with a straight arrow.
connect' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2Source
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 R2Source
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 R2Source
connectOutside :: (Renderable (Path R2) b, IsName n1, IsName n2) => n1 -> n2 -> Diagram b R2 -> Diagram b R2Source
connectOutside' :: (Renderable (Path R2) b, IsName n1, IsName n2) => ArrowOpts -> n1 -> n2 -> Diagram b R2 -> Diagram b R2Source
arrow :: Renderable (Path R2) b => Double -> Diagram b R2Source
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 R2Source
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
ArrowOpts | |
|
headColor :: Color c => Setter' ArrowOpts cSource
A lens for setting or modifying the color of an arrowhead. For
example, one may write ... (with & headColor .~ blue)
to get an
arrow with a blue head, or ... (with & headColor %~ blend 0.5
white)
to make an arrow's head a lighter color. For more general
control over the style of arrowheads, see headStyle
.
Note that the most general type of headColor
would be
(Color c, Color c') => Setter ArrowOpts ArrowOpts c c'
but that can cause problems for type inference when setting the
color. However, using it at that more general type may
occasionally be useful, for example, if you want to apply some
opacity to a color, as in ... (with & headColor %~
(`withOpacity` 0.5))
. If you want the more general type, you
can use
in place of headStyle
. styleFillColor
headColor
.
headStyle :: Lens' ArrowOpts (Style R2)Source
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)
.
tailColor :: Color c => Setter' ArrowOpts cSource
A lens for setting or modifying the color of an arrow
tail. See headColor
.
shaftColor :: Color c => Setter' ArrowOpts cSource
A lens for setting or modifying the color of an arrow
shaft. See headColor
.
straightShaft :: Trail R2Source
Straight line arrow shaft.
See Diagrams.TwoD.Arrowheads for a list of standard arrowheads and help creating your own.
module Diagrams.TwoD.Arrowheads