Randomly curved arrows in TikZ
Clash Royale CLAN TAG#URR8PPP
Any suggestions on how to draw something like this picture using TikZ?
Thanks!
tikz-pgf arrows random
add a comment |
Any suggestions on how to draw something like this picture using TikZ?
Thanks!
tikz-pgf arrows random
add a comment |
Any suggestions on how to draw something like this picture using TikZ?
Thanks!
tikz-pgf arrows random
Any suggestions on how to draw something like this picture using TikZ?
Thanks!
tikz-pgf arrows random
tikz-pgf arrows random
edited Jan 21 at 22:15
Milo
6,36721650
6,36721650
asked Jan 21 at 21:14
sorciottosorciotto
605
605
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Here is a slight extension of Milo's nice answer. The main differences (improvements?) are:
- I rewrote Alain Matthes' nice answer to allow for arbitrary functions determining the line width. Previously it was a linearly dependence, now it can be an arbitrary function such as a sine. All you need to do is to say
declare function=varyinglw(x)=1+6*sin(1.8*x);
. Apart from that, I made the code a bit more general, increased its speed (I think) and got rid ofmakeatletter
since there was nothing that cannot be achieved with commands not containing@
s. - This variation also does not nest
tikzpicture
s. Rather, the arrows a re attached in the usual way, and can be even bent.
Here's how this works
- You need to find a function that determines how thick the line is at a given position of the path. This function has the name
varyinglw
. It's argument runs from 0 to 100. So if the function has a maximum at 50, the path will have reached its maximal width in the middle. An example for a function with this feature isdeclare function=varyinglw(x)=1+6*sin(1.8*x);
below. If you want to use different functions, use scopes. Unfortunately I do not now how one can reset functions that are declared withdeclare functions
. Therefore you should keep your functions local. - If you have a very long path, you may want to increase the number of segments since otherwise it won't look smooth any more. This can be done by saying e.g.
/pgf/decoration/varying line width steps=180
as in the examples below. - Other than that you can use pretty much any path.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=red,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(7.2*x);,xshift=6cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=red]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(5.6*x);,xshift=12cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
endtikzpicture
enddocument
FUN: The mandatory animation.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
foreach Z in 0,10,...,720
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
path[use as bounding box] (-4,-4) rectangle (4,4);
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] plot[variable=z,domain=Z+90:Z+180]
(z:1+sqrt(z/90));
endscope
endtikzpicture
enddocument
ALTERNATIVE: Some additional possibilities arise with the calligraphy
library. (If I understand correctly, currently you need to download the latest version from this repository.)
documentclass[tikz,border=3.14mm]standalone
usepackagespath3
usetikzlibrarycalligraphy % need to download the repository from https://github.com/loopspace/spath3
% run "tex spath3.dtx" and then copy the spath3.sty file in the same directory
% as the tex file
usetikzlibraryarrows.meta,bending,decorations.pathreplacing
tikzsetcalligraph/.style=postaction=decorate,decoration=show path construction,
moveto code=,
lineto code=,
curveto code=
calligraphy (tikzinputsegmentfirst) .. controls
(tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
..(tikzinputsegmentlast);
,
closepath code=
begindocument
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
endtikzpicture
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150]
++ (1.5,0) to[out=-30,in=45] ++ (1,-2);
endtikzpicture
enddocument
add a comment |
This isn't a complete answer. But as a proof of concept, I tried adapting this answer from Stroke with variable thickness to make something like the arrows you want.
documentclass[tikz,margin=0.5cm]standalone
usetikzlibrarydecorations,arrows.meta
makeatletter
pgfkeys/pgf/decoration/.cd,
start color/.store in =startcolor,
end color/.store in =endcolor
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=2pt, next state=line, persistent precomputation=%
pgfmathdivide50pgfdecoratedpathlength%
letincrement=pgfmathresult%
defx0%
]
stateline[width=.5pt, persistent postcomputation=%
pgfmathadd@xincrement%
letx=pgfmathresult%
]%
pgfsetlinewidthx/20*0.005pt+pgflinewidth%
pgfsetarrows-%
pgfpathmovetopgfpointorigin%
pgfpathlinetopgfqpoint.75pt0pt%
pgfsetstrokecolorendcolor!x!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
colorendcolor!x!startcolor%
pgfusepathstroke%
makeatother
begindocument
begintikzpicture
draw [line width=2pt, decoration=width and color change,start color=black, end color=black, decorate,] plot [smooth, tension=1] coordinates (0,0) (2,0.5) (5,0.7) (3,1.5) (1,1.5) node [rotate=100] tikz draw [-Stealth[length=7mm, width=10mm]](0,0); ;
endtikzpicture
enddocument
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471204%2frandomly-curved-arrows-in-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a slight extension of Milo's nice answer. The main differences (improvements?) are:
- I rewrote Alain Matthes' nice answer to allow for arbitrary functions determining the line width. Previously it was a linearly dependence, now it can be an arbitrary function such as a sine. All you need to do is to say
declare function=varyinglw(x)=1+6*sin(1.8*x);
. Apart from that, I made the code a bit more general, increased its speed (I think) and got rid ofmakeatletter
since there was nothing that cannot be achieved with commands not containing@
s. - This variation also does not nest
tikzpicture
s. Rather, the arrows a re attached in the usual way, and can be even bent.
Here's how this works
- You need to find a function that determines how thick the line is at a given position of the path. This function has the name
varyinglw
. It's argument runs from 0 to 100. So if the function has a maximum at 50, the path will have reached its maximal width in the middle. An example for a function with this feature isdeclare function=varyinglw(x)=1+6*sin(1.8*x);
below. If you want to use different functions, use scopes. Unfortunately I do not now how one can reset functions that are declared withdeclare functions
. Therefore you should keep your functions local. - If you have a very long path, you may want to increase the number of segments since otherwise it won't look smooth any more. This can be done by saying e.g.
/pgf/decoration/varying line width steps=180
as in the examples below. - Other than that you can use pretty much any path.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=red,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(7.2*x);,xshift=6cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=red]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(5.6*x);,xshift=12cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
endtikzpicture
enddocument
FUN: The mandatory animation.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
foreach Z in 0,10,...,720
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
path[use as bounding box] (-4,-4) rectangle (4,4);
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] plot[variable=z,domain=Z+90:Z+180]
(z:1+sqrt(z/90));
endscope
endtikzpicture
enddocument
ALTERNATIVE: Some additional possibilities arise with the calligraphy
library. (If I understand correctly, currently you need to download the latest version from this repository.)
documentclass[tikz,border=3.14mm]standalone
usepackagespath3
usetikzlibrarycalligraphy % need to download the repository from https://github.com/loopspace/spath3
% run "tex spath3.dtx" and then copy the spath3.sty file in the same directory
% as the tex file
usetikzlibraryarrows.meta,bending,decorations.pathreplacing
tikzsetcalligraph/.style=postaction=decorate,decoration=show path construction,
moveto code=,
lineto code=,
curveto code=
calligraphy (tikzinputsegmentfirst) .. controls
(tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
..(tikzinputsegmentlast);
,
closepath code=
begindocument
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
endtikzpicture
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150]
++ (1.5,0) to[out=-30,in=45] ++ (1,-2);
endtikzpicture
enddocument
add a comment |
Here is a slight extension of Milo's nice answer. The main differences (improvements?) are:
- I rewrote Alain Matthes' nice answer to allow for arbitrary functions determining the line width. Previously it was a linearly dependence, now it can be an arbitrary function such as a sine. All you need to do is to say
declare function=varyinglw(x)=1+6*sin(1.8*x);
. Apart from that, I made the code a bit more general, increased its speed (I think) and got rid ofmakeatletter
since there was nothing that cannot be achieved with commands not containing@
s. - This variation also does not nest
tikzpicture
s. Rather, the arrows a re attached in the usual way, and can be even bent.
Here's how this works
- You need to find a function that determines how thick the line is at a given position of the path. This function has the name
varyinglw
. It's argument runs from 0 to 100. So if the function has a maximum at 50, the path will have reached its maximal width in the middle. An example for a function with this feature isdeclare function=varyinglw(x)=1+6*sin(1.8*x);
below. If you want to use different functions, use scopes. Unfortunately I do not now how one can reset functions that are declared withdeclare functions
. Therefore you should keep your functions local. - If you have a very long path, you may want to increase the number of segments since otherwise it won't look smooth any more. This can be done by saying e.g.
/pgf/decoration/varying line width steps=180
as in the examples below. - Other than that you can use pretty much any path.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=red,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(7.2*x);,xshift=6cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=red]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(5.6*x);,xshift=12cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
endtikzpicture
enddocument
FUN: The mandatory animation.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
foreach Z in 0,10,...,720
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
path[use as bounding box] (-4,-4) rectangle (4,4);
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] plot[variable=z,domain=Z+90:Z+180]
(z:1+sqrt(z/90));
endscope
endtikzpicture
enddocument
ALTERNATIVE: Some additional possibilities arise with the calligraphy
library. (If I understand correctly, currently you need to download the latest version from this repository.)
documentclass[tikz,border=3.14mm]standalone
usepackagespath3
usetikzlibrarycalligraphy % need to download the repository from https://github.com/loopspace/spath3
% run "tex spath3.dtx" and then copy the spath3.sty file in the same directory
% as the tex file
usetikzlibraryarrows.meta,bending,decorations.pathreplacing
tikzsetcalligraph/.style=postaction=decorate,decoration=show path construction,
moveto code=,
lineto code=,
curveto code=
calligraphy (tikzinputsegmentfirst) .. controls
(tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
..(tikzinputsegmentlast);
,
closepath code=
begindocument
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
endtikzpicture
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150]
++ (1.5,0) to[out=-30,in=45] ++ (1,-2);
endtikzpicture
enddocument
add a comment |
Here is a slight extension of Milo's nice answer. The main differences (improvements?) are:
- I rewrote Alain Matthes' nice answer to allow for arbitrary functions determining the line width. Previously it was a linearly dependence, now it can be an arbitrary function such as a sine. All you need to do is to say
declare function=varyinglw(x)=1+6*sin(1.8*x);
. Apart from that, I made the code a bit more general, increased its speed (I think) and got rid ofmakeatletter
since there was nothing that cannot be achieved with commands not containing@
s. - This variation also does not nest
tikzpicture
s. Rather, the arrows a re attached in the usual way, and can be even bent.
Here's how this works
- You need to find a function that determines how thick the line is at a given position of the path. This function has the name
varyinglw
. It's argument runs from 0 to 100. So if the function has a maximum at 50, the path will have reached its maximal width in the middle. An example for a function with this feature isdeclare function=varyinglw(x)=1+6*sin(1.8*x);
below. If you want to use different functions, use scopes. Unfortunately I do not now how one can reset functions that are declared withdeclare functions
. Therefore you should keep your functions local. - If you have a very long path, you may want to increase the number of segments since otherwise it won't look smooth any more. This can be done by saying e.g.
/pgf/decoration/varying line width steps=180
as in the examples below. - Other than that you can use pretty much any path.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=red,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(7.2*x);,xshift=6cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=red]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(5.6*x);,xshift=12cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
endtikzpicture
enddocument
FUN: The mandatory animation.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
foreach Z in 0,10,...,720
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
path[use as bounding box] (-4,-4) rectangle (4,4);
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] plot[variable=z,domain=Z+90:Z+180]
(z:1+sqrt(z/90));
endscope
endtikzpicture
enddocument
ALTERNATIVE: Some additional possibilities arise with the calligraphy
library. (If I understand correctly, currently you need to download the latest version from this repository.)
documentclass[tikz,border=3.14mm]standalone
usepackagespath3
usetikzlibrarycalligraphy % need to download the repository from https://github.com/loopspace/spath3
% run "tex spath3.dtx" and then copy the spath3.sty file in the same directory
% as the tex file
usetikzlibraryarrows.meta,bending,decorations.pathreplacing
tikzsetcalligraph/.style=postaction=decorate,decoration=show path construction,
moveto code=,
lineto code=,
curveto code=
calligraphy (tikzinputsegmentfirst) .. controls
(tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
..(tikzinputsegmentlast);
,
closepath code=
begindocument
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
endtikzpicture
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150]
++ (1.5,0) to[out=-30,in=45] ++ (1,-2);
endtikzpicture
enddocument
Here is a slight extension of Milo's nice answer. The main differences (improvements?) are:
- I rewrote Alain Matthes' nice answer to allow for arbitrary functions determining the line width. Previously it was a linearly dependence, now it can be an arbitrary function such as a sine. All you need to do is to say
declare function=varyinglw(x)=1+6*sin(1.8*x);
. Apart from that, I made the code a bit more general, increased its speed (I think) and got rid ofmakeatletter
since there was nothing that cannot be achieved with commands not containing@
s. - This variation also does not nest
tikzpicture
s. Rather, the arrows a re attached in the usual way, and can be even bent.
Here's how this works
- You need to find a function that determines how thick the line is at a given position of the path. This function has the name
varyinglw
. It's argument runs from 0 to 100. So if the function has a maximum at 50, the path will have reached its maximal width in the middle. An example for a function with this feature isdeclare function=varyinglw(x)=1+6*sin(1.8*x);
below. If you want to use different functions, use scopes. Unfortunately I do not now how one can reset functions that are declared withdeclare functions
. Therefore you should keep your functions local. - If you have a very long path, you may want to increase the number of segments since otherwise it won't look smooth any more. This can be done by saying e.g.
/pgf/decoration/varying line width steps=180
as in the examples below. - Other than that you can use pretty much any path.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=red,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(7.2*x);,xshift=6cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=red]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
beginscope[declare function=varyinglw(x)=4-3*cos(5.6*x);,xshift=12cm]
draw[varying arrow] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
draw[varying arrow,/pgf/decoration/varying line width steps=180]
(0,-3) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0)
to[out=45,in=45] ++ (-2,1);
draw[varying arrow,/pgf/decoration/varying line width steps=180,
/pgf/decoration/start color=yellow,/pgf/decoration/end color=blue]
(0,-5) to[out=15,in=165] ++ (2,0) to[out=-15,in=90] ++ (1,-1)
to[out=-90,in=-20] ++ (-1.5,0);
endscope
endtikzpicture
enddocument
FUN: The mandatory animation.
documentclass[tikz,border=3.14mm]standalone
usetikzlibrarydecorations,arrows.meta,bending
begindocument
pgfkeys/pgf/decoration/.cd,
start color/.store in=startcolor,
start color=black,
end color/.store in=endcolor,
end color=black,
varying line width steps/.initial=100
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=0pt, next state=line, persistent precomputation=%
pgfmathparsepgfdecoratedpathlength/pgfkeysvalueof/pgf/decoration/varying line width steps%
letincrement=pgfmathresult%
defx0%
]
stateline[width=increment pt, persistent postcomputation=%
pgfmathsetmacroxx+increment
,next state=line]%
pgfmathparseifthenelse(x<pgfdecoratedpathlength-5mm,varyinglw(100*(x/pgfdecoratedpathlength)),
varyinglw(100*((pgfdecoratedpathlength-5mm)/pgfdecoratedpathlength))*(pgfdecoratedpathlength-x)/14) )
pgfsetlinewidthpgfmathresult pt%
pgfpathmovetopgfpointorigin%
pgfmathsetmacrosteplength1.4*increment
pgfpathlinetopgfqpointsteplength pt0pt%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
pgfsetstrokecolorendcolor!y!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
pgfmathsetmacroy100*(x/pgfdecoratedpathlength)
colorendcolor!y!startcolor%
pgfusepathstroke%
foreach Z in 0,10,...,720
begintikzpicture[varying arrow/.style=-Stealth[length=5mm,width=3.2mm,bend],color=endcolor,
postaction=/utils/exec=pgfsetarrows-,decorate,decoration=width and color change
]
path[use as bounding box] (-4,-4) rectangle (4,4);
beginscope[declare function=varyinglw(x)=1+6*sin(1.8*x);]
draw[varying arrow] plot[variable=z,domain=Z+90:Z+180]
(z:1+sqrt(z/90));
endscope
endtikzpicture
enddocument
ALTERNATIVE: Some additional possibilities arise with the calligraphy
library. (If I understand correctly, currently you need to download the latest version from this repository.)
documentclass[tikz,border=3.14mm]standalone
usepackagespath3
usetikzlibrarycalligraphy % need to download the repository from https://github.com/loopspace/spath3
% run "tex spath3.dtx" and then copy the spath3.sty file in the same directory
% as the tex file
usetikzlibraryarrows.meta,bending,decorations.pathreplacing
tikzsetcalligraph/.style=postaction=decorate,decoration=show path construction,
moveto code=,
lineto code=,
curveto code=
calligraphy (tikzinputsegmentfirst) .. controls
(tikzinputsegmentsupporta) and (tikzinputsegmentsupportb)
..(tikzinputsegmentlast);
,
closepath code=
begindocument
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150] ++ (1.5,0) to[out=-30,in=-135] ++ (3,0);
endtikzpicture
begintikzpicture[line width=1pt]
pen (-135:.125) -- (45:.125) ;
draw[calligraph,Stealth[length=5mm,width=3.2mm,bend]-] (0,0) to[out=45,in=150]
++ (1.5,0) to[out=-30,in=45] ++ (1,-2);
endtikzpicture
enddocument
edited Jan 22 at 18:51
answered Jan 22 at 0:09
marmotmarmot
98.4k4113218
98.4k4113218
add a comment |
add a comment |
This isn't a complete answer. But as a proof of concept, I tried adapting this answer from Stroke with variable thickness to make something like the arrows you want.
documentclass[tikz,margin=0.5cm]standalone
usetikzlibrarydecorations,arrows.meta
makeatletter
pgfkeys/pgf/decoration/.cd,
start color/.store in =startcolor,
end color/.store in =endcolor
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=2pt, next state=line, persistent precomputation=%
pgfmathdivide50pgfdecoratedpathlength%
letincrement=pgfmathresult%
defx0%
]
stateline[width=.5pt, persistent postcomputation=%
pgfmathadd@xincrement%
letx=pgfmathresult%
]%
pgfsetlinewidthx/20*0.005pt+pgflinewidth%
pgfsetarrows-%
pgfpathmovetopgfpointorigin%
pgfpathlinetopgfqpoint.75pt0pt%
pgfsetstrokecolorendcolor!x!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
colorendcolor!x!startcolor%
pgfusepathstroke%
makeatother
begindocument
begintikzpicture
draw [line width=2pt, decoration=width and color change,start color=black, end color=black, decorate,] plot [smooth, tension=1] coordinates (0,0) (2,0.5) (5,0.7) (3,1.5) (1,1.5) node [rotate=100] tikz draw [-Stealth[length=7mm, width=10mm]](0,0); ;
endtikzpicture
enddocument
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
add a comment |
This isn't a complete answer. But as a proof of concept, I tried adapting this answer from Stroke with variable thickness to make something like the arrows you want.
documentclass[tikz,margin=0.5cm]standalone
usetikzlibrarydecorations,arrows.meta
makeatletter
pgfkeys/pgf/decoration/.cd,
start color/.store in =startcolor,
end color/.store in =endcolor
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=2pt, next state=line, persistent precomputation=%
pgfmathdivide50pgfdecoratedpathlength%
letincrement=pgfmathresult%
defx0%
]
stateline[width=.5pt, persistent postcomputation=%
pgfmathadd@xincrement%
letx=pgfmathresult%
]%
pgfsetlinewidthx/20*0.005pt+pgflinewidth%
pgfsetarrows-%
pgfpathmovetopgfpointorigin%
pgfpathlinetopgfqpoint.75pt0pt%
pgfsetstrokecolorendcolor!x!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
colorendcolor!x!startcolor%
pgfusepathstroke%
makeatother
begindocument
begintikzpicture
draw [line width=2pt, decoration=width and color change,start color=black, end color=black, decorate,] plot [smooth, tension=1] coordinates (0,0) (2,0.5) (5,0.7) (3,1.5) (1,1.5) node [rotate=100] tikz draw [-Stealth[length=7mm, width=10mm]](0,0); ;
endtikzpicture
enddocument
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
add a comment |
This isn't a complete answer. But as a proof of concept, I tried adapting this answer from Stroke with variable thickness to make something like the arrows you want.
documentclass[tikz,margin=0.5cm]standalone
usetikzlibrarydecorations,arrows.meta
makeatletter
pgfkeys/pgf/decoration/.cd,
start color/.store in =startcolor,
end color/.store in =endcolor
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=2pt, next state=line, persistent precomputation=%
pgfmathdivide50pgfdecoratedpathlength%
letincrement=pgfmathresult%
defx0%
]
stateline[width=.5pt, persistent postcomputation=%
pgfmathadd@xincrement%
letx=pgfmathresult%
]%
pgfsetlinewidthx/20*0.005pt+pgflinewidth%
pgfsetarrows-%
pgfpathmovetopgfpointorigin%
pgfpathlinetopgfqpoint.75pt0pt%
pgfsetstrokecolorendcolor!x!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
colorendcolor!x!startcolor%
pgfusepathstroke%
makeatother
begindocument
begintikzpicture
draw [line width=2pt, decoration=width and color change,start color=black, end color=black, decorate,] plot [smooth, tension=1] coordinates (0,0) (2,0.5) (5,0.7) (3,1.5) (1,1.5) node [rotate=100] tikz draw [-Stealth[length=7mm, width=10mm]](0,0); ;
endtikzpicture
enddocument
This isn't a complete answer. But as a proof of concept, I tried adapting this answer from Stroke with variable thickness to make something like the arrows you want.
documentclass[tikz,margin=0.5cm]standalone
usetikzlibrarydecorations,arrows.meta
makeatletter
pgfkeys/pgf/decoration/.cd,
start color/.store in =startcolor,
end color/.store in =endcolor
pgfdeclaredecorationwidth and color changeinitial
stateinitial[width=2pt, next state=line, persistent precomputation=%
pgfmathdivide50pgfdecoratedpathlength%
letincrement=pgfmathresult%
defx0%
]
stateline[width=.5pt, persistent postcomputation=%
pgfmathadd@xincrement%
letx=pgfmathresult%
]%
pgfsetlinewidthx/20*0.005pt+pgflinewidth%
pgfsetarrows-%
pgfpathmovetopgfpointorigin%
pgfpathlinetopgfqpoint.75pt0pt%
pgfsetstrokecolorendcolor!x!startcolor%
pgfusepathstroke%
statefinal%
pgfsetlinewidthpgflinewidth%
pgfpathmovetopgfpointorigin%
colorendcolor!x!startcolor%
pgfusepathstroke%
makeatother
begindocument
begintikzpicture
draw [line width=2pt, decoration=width and color change,start color=black, end color=black, decorate,] plot [smooth, tension=1] coordinates (0,0) (2,0.5) (5,0.7) (3,1.5) (1,1.5) node [rotate=100] tikz draw [-Stealth[length=7mm, width=10mm]](0,0); ;
endtikzpicture
enddocument
answered Jan 21 at 22:13
MiloMilo
6,36721650
6,36721650
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
add a comment |
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
4
4
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
@marmot I'm actually thinking about forbidding nesting in a future version of PGF. It's just not fixable and always calls for trouble.
– Henri Menke
Jan 22 at 1:26
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471204%2frandomly-curved-arrows-in-tikz%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown