6
$\begingroup$

I would like to change the how the ends of the spline arrows in my figure are rendered to be "rounded", but

Graphics@{CapForm["Round"], Thick, Arrow[BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, SplineWeights -> {3, 5, 4, 5}], .05]}

has no effect, yielding.

How do I get my spline based arrows to have rounded ends?


If it matters, these will be used as part of EdgeShapeFunction in a Graph.

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Use ArrowHeads with custom arrow graphics... $\endgroup$
    – ciao
    Commented Apr 11, 2015 at 20:42

2 Answers 2

6
$\begingroup$

Another take based on @rasher's comment:

Graphics[{Thickness[.02], 
  Arrowheads[{{-.1, 0, Graphics[{Thickness[.02], CapForm["Round"], 
       Line[{{-1, 0}, {0, 0}}]}]}, {.2, 1}}], 
  Arrow[BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, 
    SplineWeights -> {3, 5, 4, 5}], .05]}]

enter image description here

Update:

What if the arrow is dashed or dotted?

Overlaying BSplineCurve (without Arrow) with a transparent Arrow with some manual adjustments seems to work:

ah = GraphElementData["FilledArrow", "ArrowSize" -> 0.1][{{0.`, 0.`}, 
      {1.`, 0.`}}][[1, 1, 1, 3, 1]];
g1 = Graphics[{Thickness[.03], Red, Dashing[.02], CapForm["Round"], 
    BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, 
     SplineWeights -> {3, 5, 4, 5}]}, ImageSize -> 300];
g2 = Graphics[{Thickness[.03], 
    Arrowheads[{{.15, 1, {ah /. FilledCurve[x__] :> {Opacity[1], Red, 
                FilledCurve[x]}, .5}}}],
    Red, Dashing[.02], CapForm["Round"], 
    BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {9.2, 10.05}}, 
      SplineWeights -> {3, 5, 4, 5}],
    Opacity[0], 
    Arrow[BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, 
      SplineWeights -> {3, 5, 4, 5}]]}, ImageSize -> 300];
Row[{g1, g2}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Promising. What if the arrow is dashed or dotted? $\endgroup$
    – orome
    Commented Apr 13, 2015 at 19:44
  • 1
    $\begingroup$ @raxa, I think it would be quite a challenge to play with the Arrowheads settings to get Dotted and Dashed curves with rounded caps. Perhaps, overlaying BSplineCurve (without Arrow) with a transparent Arrow might work -- but i haven't tried it yet. $\endgroup$
    – kglr
    Commented Apr 14, 2015 at 9:21
  • $\begingroup$ ... for Dashed curves, although too manual/ fragile/specific, a modification of Arrowheads along the following lines may work: Graphics[{Thickness[.02], Arrowheads[{{-.1, 0, Graphics[{PointSize[.02], CapForm["Round"], Point[{-.05, 0}]}]}, {.2, 1}}], Dashed, Arrow[BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, SplineWeights -> {3, 5, 4, 5}], .05]}] $\endgroup$
    – kglr
    Commented Apr 14, 2015 at 9:27
  • $\begingroup$ @raxacoricofallapatorius, thanks for the accept. $\endgroup$
    – kglr
    Commented Apr 14, 2015 at 13:57
1
$\begingroup$

Here's a rough version of comment:

ah = Graphics[{Line[{{{-1, 1/2}, {.04, .2}}, {{-1, -1/2}, {.04, -.2}}}], 
   Circle[{.01, 0}, .2, {-4/9 Pi, 4/9 Pi}]}]

Graphics@{Arrowheads[{{Automatic, Automatic, ah}}], CapForm["Round"], 
  Thick, Arrow[
   BSplineCurve[{{0, 0}, {4, 7}, {2, 11}, {10, 10}}, 
    SplineWeights -> {3, 5, 4, 5}], .05]}

enter image description here

$\endgroup$
1
  • $\begingroup$ I'm trying to get the butt (start) of the arrow rounded. $\endgroup$
    – orome
    Commented Apr 11, 2015 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.