Dashed trajectory encircling two segmentsTikZ, a selfloop without an arrow at the endHow to create a line with “radial” shading?Drawing a polyline between two nodes in tikzHow can I create “unbound” horizontal bar plots?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to restrict lines by intersections with other lines pgfplotComplex TikZ graphs from multiple sources with subgraphs labeling an edgehow to combine features of tikz-picture with tikz-cd

Question about the most suitable position for a bishop here

Synaptic Static - when to roll the d6?

What is the highest power supply a Raspberry pi 3 B can handle without getting damaged?

In a list with unique pairs A, B, how can I sort them so that the last B is the first A in the next pair?

Why is Havana covered in 5-digit numbers in Our Man in Havana?

Definition of 'vrit'

Am I legally required to provide a (GPL licensed) source code even after a project is abandoned?

I just entered the USA without passport control at Atlanta airport

King or Queen-Which piece is which?

Is there any way to revive my Sim?

Setting up the trap

What preparations would Hubble have needed to return in a Shuttle?

First occurrence in the Sixers sequence

Can a character learn spells from someone else's spellbook and then sell it?

Counterfeit checks were created for my account. How does this type of fraud work?

Would a 7805 5 V regulator drain a 9 V battery?

How can I take pictures like these examples with a yellowish tone and point & shoot film camera look?

Why things float in space, though there is always gravity of our star is present

Basic power tool set for Home repair and simple projects

I have found ports on my Samsung smart tv running a display service. What can I do with it?

How "fast" do astronomical events occur?

What is this word in a sample of blackletter script?

"Correct me if I'm wrong"

If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?



Dashed trajectory encircling two segments


TikZ, a selfloop without an arrow at the endHow to create a line with “radial” shading?Drawing a polyline between two nodes in tikzHow can I create “unbound” horizontal bar plots?TikZ: Drawing an arc from an intersection to an intersectionDrawing rectilinear curves in Tikz, aka an Etch-a-Sketch drawingLine up nested tikz enviroments or how to get rid of themHow to restrict lines by intersections with other lines pgfplotComplex TikZ graphs from multiple sources with subgraphs labeling an edgehow to combine features of tikz-picture with tikz-cd






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








6















In TikZ, I want to draw two segments (black) and a dashed trajectory (red) encircling these segments, as shown in the picture. Is there a way to easily draw the dashed trajectory just based on the coordinates of the two segments?



enter image description here



Here is my attempt:



begintikzpicture
draw [thick] (1,1) -- (2,2);
draw [thick] (2,2) -- (2,3.5);
draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);
endtikzpicture


It doesn't look very nice, and I wasn't able to make the curve.



enter image description here










share|improve this question









New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1





    Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

    – Raaja
    Jun 10 at 7:23











  • @Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

    – doe
    Jun 10 at 7:33







  • 2





    You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

    – Raaja
    Jun 10 at 7:46












  • @Raaja I have added my efforts.

    – doe
    Jun 10 at 8:18











  • You are welcome and you get my +1. Moreover, from next time, please make it compilable.

    – Raaja
    Jun 10 at 9:04

















6















In TikZ, I want to draw two segments (black) and a dashed trajectory (red) encircling these segments, as shown in the picture. Is there a way to easily draw the dashed trajectory just based on the coordinates of the two segments?



enter image description here



Here is my attempt:



begintikzpicture
draw [thick] (1,1) -- (2,2);
draw [thick] (2,2) -- (2,3.5);
draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);
endtikzpicture


It doesn't look very nice, and I wasn't able to make the curve.



enter image description here










share|improve this question









New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1





    Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

    – Raaja
    Jun 10 at 7:23











  • @Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

    – doe
    Jun 10 at 7:33







  • 2





    You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

    – Raaja
    Jun 10 at 7:46












  • @Raaja I have added my efforts.

    – doe
    Jun 10 at 8:18











  • You are welcome and you get my +1. Moreover, from next time, please make it compilable.

    – Raaja
    Jun 10 at 9:04













6












6








6


1






In TikZ, I want to draw two segments (black) and a dashed trajectory (red) encircling these segments, as shown in the picture. Is there a way to easily draw the dashed trajectory just based on the coordinates of the two segments?



enter image description here



Here is my attempt:



begintikzpicture
draw [thick] (1,1) -- (2,2);
draw [thick] (2,2) -- (2,3.5);
draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);
endtikzpicture


It doesn't look very nice, and I wasn't able to make the curve.



enter image description here










share|improve this question









New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











In TikZ, I want to draw two segments (black) and a dashed trajectory (red) encircling these segments, as shown in the picture. Is there a way to easily draw the dashed trajectory just based on the coordinates of the two segments?



enter image description here



Here is my attempt:



begintikzpicture
draw [thick] (1,1) -- (2,2);
draw [thick] (2,2) -- (2,3.5);
draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);
endtikzpicture


It doesn't look very nice, and I wasn't able to make the curve.



enter image description here







tikz-pgf






share|improve this question









New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited Jun 10 at 8:17







doe













New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked Jun 10 at 7:01









doedoe

334




334




New contributor



doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









  • 1





    Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

    – Raaja
    Jun 10 at 7:23











  • @Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

    – doe
    Jun 10 at 7:33







  • 2





    You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

    – Raaja
    Jun 10 at 7:46












  • @Raaja I have added my efforts.

    – doe
    Jun 10 at 8:18











  • You are welcome and you get my +1. Moreover, from next time, please make it compilable.

    – Raaja
    Jun 10 at 9:04












  • 1





    Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

    – Raaja
    Jun 10 at 7:23











  • @Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

    – doe
    Jun 10 at 7:33







  • 2





    You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

    – Raaja
    Jun 10 at 7:46












  • @Raaja I have added my efforts.

    – doe
    Jun 10 at 8:18











  • You are welcome and you get my +1. Moreover, from next time, please make it compilable.

    – Raaja
    Jun 10 at 9:04







1




1





Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

– Raaja
Jun 10 at 7:23





Welcome to TEX.SE. please show us what you have tried so far. This is not a just-do-it-for-me site.

– Raaja
Jun 10 at 7:23













@Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

– doe
Jun 10 at 7:33






@Raaja Thank you. I have tried searching for this on Google and a number of TikZ tutorials, but could not find how to do this. One approach would be to draw each "dash" separately, but that would be extremely tedious and I can't imagine it's the best approach. Also, I don't think it would work well for the curved part.

– doe
Jun 10 at 7:33





2




2





You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

– Raaja
Jun 10 at 7:46






You can always start something and shows us what you have done. We can take that as a start and then give you (close to) what you want instead of starting from scratch.

– Raaja
Jun 10 at 7:46














@Raaja I have added my efforts.

– doe
Jun 10 at 8:18





@Raaja I have added my efforts.

– doe
Jun 10 at 8:18













You are welcome and you get my +1. Moreover, from next time, please make it compilable.

– Raaja
Jun 10 at 9:04





You are welcome and you get my +1. Moreover, from next time, please make it compilable.

– Raaja
Jun 10 at 9:04










2 Answers
2






active

oldest

votes


















7














If you could accept not being dashed, a round cap can help:



documentclass[tikz, border=2mm]standalone

begindocument
begintikzpicture
draw [thick] (1,1) -- (2,2);
draw [thick] (2,2) -- (2,3.5);
draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);

beginscope[xshift=2cm]
draw[line cap=round, red!30, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
draw (1,1)--(2,2)--(2,3.5);
endscope

beginscope[xshift=4cm]
draw[line cap=round, line width=3mm] (1,1)--(2,2)--(2,3.5);
draw[line cap=round, white, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
draw (1,1)--(2,2)--(2,3.5);
endscope
endtikzpicture
enddocument


enter image description here



Update: with some patience and hobby library you could do something like:



documentclass[tikz, border=2mm]standalone
usetikzlibraryhobby

begindocument
begintikzpicture
draw (1,1) node (a) --(2,2) node (b) --(2,3.5) node[rotate=45] (c) ;
draw[dashed, use Hobby shortcut] (a.south west) to[closed, curve through=(a.north west) .. (b.north west) .. (c.north west) .. (c.north east) .. (c.south east) .. (b.south east) .. (a.south east)] cycle;
endtikzpicture
enddocument


enter image description here






share|improve this answer
































    3














    The following draws halos around simple paths as the one above. You only need to record the path



    draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);


    and then can draw a halo via



    draw[dashed,halo];


    enter image description here



    documentclass[tikz,border=3.14mm]standalone
    usetikzlibrarydecorations.markings
    newcounterhalo
    tikzsetrecord path/.style=/utils/exec=tikzsethalo pars/.cd,#1,
    decorate,decoration=markings,mark=at position 0 with
    setcounterhalo1%typeoutpgfdecoratedpathlength
    path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
    (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
    (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-1)
    (-pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-A-2)
    (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-3);
    pgfmathsetmacromystep(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/int(1+(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/pgfkeysvalueof/tikz/halo pars/step)
    xdefmystepmystep,
    mark=between positions pgfkeysvalueof/tikz/halo pars/step and pgfdecoratedpathlength-pgfkeysvalueof/tikz/halo pars/step step mystep pt with stepcounterhalo
    path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
    (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo);,
    mark=at position 1 with stepcounterhalo
    path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
    (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
    (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-1)
    (pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-B-2)
    (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-3);
    xdefLstHaloCoords(halo-A-1) (halo-A-2) (halo-A-3)
    foreach XX in 1,...,numbervaluehalo
    xdefLstHaloCoordsLstHaloCoordsspace (halo-L-XX)
    xdefLstHaloCoordsLstHaloCoordsspace (halo-B-1) (halo-B-2) (halo-B-3)
    foreach XX in numbervaluehalo,thenumexprnumbervaluehalo-1,...,1
    xdefLstHaloCoordsLstHaloCoordsspace (halo-R-XX)
    ,
    halo/.style=insert path=plot[smooth,samples at=1,...,numbervaluebracep,variable=x]
    (bracep-x),halo/.style=insert path=plot[smooth cycle] coordinates LstHaloCoords ,
    halo pars/.cd,dist/.initial=5pt,step/.initial=2pt
    begindocument
    begintikzpicture
    draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
    draw[dashed,halo];
    endtikzpicture
    enddocument


    The halo path is known to TikZ so it can be used for all sorts of things like intersections or fill with pattern (needs the libraries intersections or patterns), e.g.



    draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
    draw[red,pattern=north west lines,pattern color=blue,halo];


    enter image description here



    As you can see, the result is not perfect, but can be improved by playing with the step parameter (I chose this on purpose in order not to deceive users). An automatically nice solution that works with much more complicated, in particular self-intersecting, paths is much harder to obtain. However, the above works with curves, too, i.e. not just with straight lines.




    Note also that if I only take your dashed contour, add rounded corners and replace the last coordinate by cycle (so that the last corner is also rounded), I get



    enter image description here



    documentclass[tikz,border=3.14mm]standalone
    begindocument
    begintikzpicture
    draw [thick] (1,1) -- (2,2);
    draw [thick] (2,2) -- (2,3.5);
    draw [dashed,rounded corners] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) --
    (0.8,1) -- (1.1,0.8) -- cycle;
    endtikzpicture
    enddocument


    Things look arguably even better if one draws the fist line in one stretch and takes into account the slope of the lower leg when drawing the contour.



    documentclass[tikz,border=3.14mm]standalone
    begindocument
    begintikzpicture
    draw [thick] (1,1) -- (2,2) -- (2,3.5);
    draw [dashed,rounded corners] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
    (0.8,1) -- (1.1,0.8) -- cycle;
    endtikzpicture
    enddocument


    enter image description here



    If you want the dash pattern to close, use



    documentclass[tikz,border=3.14mm]standalone
    usetikzlibrarydecorations.markings
    begindocument
    begintikzpicture
    draw [thick] (1,1) -- (2,2) -- (2,3.5);
    path [rounded corners,preaction=decorate,decoration=markings,mark=at position 0 with %
    pgfmathsetmacromyonpgfdecoratedpathlength/50
    xdefmyonmyon,postaction=draw,dash pattern=on myon pt off myon pt] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
    (0.8,1) -- (1.1,0.8) -- cycle;
    endtikzpicture
    enddocument


    enter image description here






    share|improve this answer

























      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
      );



      );






      doe is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f495067%2fdashed-trajectory-encircling-two-segments%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









      7














      If you could accept not being dashed, a round cap can help:



      documentclass[tikz, border=2mm]standalone

      begindocument
      begintikzpicture
      draw [thick] (1,1) -- (2,2);
      draw [thick] (2,2) -- (2,3.5);
      draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);

      beginscope[xshift=2cm]
      draw[line cap=round, red!30, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
      draw (1,1)--(2,2)--(2,3.5);
      endscope

      beginscope[xshift=4cm]
      draw[line cap=round, line width=3mm] (1,1)--(2,2)--(2,3.5);
      draw[line cap=round, white, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
      draw (1,1)--(2,2)--(2,3.5);
      endscope
      endtikzpicture
      enddocument


      enter image description here



      Update: with some patience and hobby library you could do something like:



      documentclass[tikz, border=2mm]standalone
      usetikzlibraryhobby

      begindocument
      begintikzpicture
      draw (1,1) node (a) --(2,2) node (b) --(2,3.5) node[rotate=45] (c) ;
      draw[dashed, use Hobby shortcut] (a.south west) to[closed, curve through=(a.north west) .. (b.north west) .. (c.north west) .. (c.north east) .. (c.south east) .. (b.south east) .. (a.south east)] cycle;
      endtikzpicture
      enddocument


      enter image description here






      share|improve this answer





























        7














        If you could accept not being dashed, a round cap can help:



        documentclass[tikz, border=2mm]standalone

        begindocument
        begintikzpicture
        draw [thick] (1,1) -- (2,2);
        draw [thick] (2,2) -- (2,3.5);
        draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);

        beginscope[xshift=2cm]
        draw[line cap=round, red!30, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
        draw (1,1)--(2,2)--(2,3.5);
        endscope

        beginscope[xshift=4cm]
        draw[line cap=round, line width=3mm] (1,1)--(2,2)--(2,3.5);
        draw[line cap=round, white, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
        draw (1,1)--(2,2)--(2,3.5);
        endscope
        endtikzpicture
        enddocument


        enter image description here



        Update: with some patience and hobby library you could do something like:



        documentclass[tikz, border=2mm]standalone
        usetikzlibraryhobby

        begindocument
        begintikzpicture
        draw (1,1) node (a) --(2,2) node (b) --(2,3.5) node[rotate=45] (c) ;
        draw[dashed, use Hobby shortcut] (a.south west) to[closed, curve through=(a.north west) .. (b.north west) .. (c.north west) .. (c.north east) .. (c.south east) .. (b.south east) .. (a.south east)] cycle;
        endtikzpicture
        enddocument


        enter image description here






        share|improve this answer



























          7












          7








          7







          If you could accept not being dashed, a round cap can help:



          documentclass[tikz, border=2mm]standalone

          begindocument
          begintikzpicture
          draw [thick] (1,1) -- (2,2);
          draw [thick] (2,2) -- (2,3.5);
          draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);

          beginscope[xshift=2cm]
          draw[line cap=round, red!30, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
          draw (1,1)--(2,2)--(2,3.5);
          endscope

          beginscope[xshift=4cm]
          draw[line cap=round, line width=3mm] (1,1)--(2,2)--(2,3.5);
          draw[line cap=round, white, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
          draw (1,1)--(2,2)--(2,3.5);
          endscope
          endtikzpicture
          enddocument


          enter image description here



          Update: with some patience and hobby library you could do something like:



          documentclass[tikz, border=2mm]standalone
          usetikzlibraryhobby

          begindocument
          begintikzpicture
          draw (1,1) node (a) --(2,2) node (b) --(2,3.5) node[rotate=45] (c) ;
          draw[dashed, use Hobby shortcut] (a.south west) to[closed, curve through=(a.north west) .. (b.north west) .. (c.north west) .. (c.north east) .. (c.south east) .. (b.south east) .. (a.south east)] cycle;
          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer















          If you could accept not being dashed, a round cap can help:



          documentclass[tikz, border=2mm]standalone

          begindocument
          begintikzpicture
          draw [thick] (1,1) -- (2,2);
          draw [thick] (2,2) -- (2,3.5);
          draw [dashed] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) -- (0.8,1) -- (1.1,0.8) -- (2.2,2);

          beginscope[xshift=2cm]
          draw[line cap=round, red!30, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
          draw (1,1)--(2,2)--(2,3.5);
          endscope

          beginscope[xshift=4cm]
          draw[line cap=round, line width=3mm] (1,1)--(2,2)--(2,3.5);
          draw[line cap=round, white, line width=2.5mm] (1,1)--(2,2)--(2,3.5);
          draw (1,1)--(2,2)--(2,3.5);
          endscope
          endtikzpicture
          enddocument


          enter image description here



          Update: with some patience and hobby library you could do something like:



          documentclass[tikz, border=2mm]standalone
          usetikzlibraryhobby

          begindocument
          begintikzpicture
          draw (1,1) node (a) --(2,2) node (b) --(2,3.5) node[rotate=45] (c) ;
          draw[dashed, use Hobby shortcut] (a.south west) to[closed, curve through=(a.north west) .. (b.north west) .. (c.north west) .. (c.north east) .. (c.south east) .. (b.south east) .. (a.south east)] cycle;
          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 10 at 10:34

























          answered Jun 10 at 8:48









          IgnasiIgnasi

          97.5k6180327




          97.5k6180327























              3














              The following draws halos around simple paths as the one above. You only need to record the path



              draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);


              and then can draw a halo via



              draw[dashed,halo];


              enter image description here



              documentclass[tikz,border=3.14mm]standalone
              usetikzlibrarydecorations.markings
              newcounterhalo
              tikzsetrecord path/.style=/utils/exec=tikzsethalo pars/.cd,#1,
              decorate,decoration=markings,mark=at position 0 with
              setcounterhalo1%typeoutpgfdecoratedpathlength
              path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
              (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
              (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-1)
              (-pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-A-2)
              (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-3);
              pgfmathsetmacromystep(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/int(1+(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/pgfkeysvalueof/tikz/halo pars/step)
              xdefmystepmystep,
              mark=between positions pgfkeysvalueof/tikz/halo pars/step and pgfdecoratedpathlength-pgfkeysvalueof/tikz/halo pars/step step mystep pt with stepcounterhalo
              path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
              (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo);,
              mark=at position 1 with stepcounterhalo
              path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
              (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
              (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-1)
              (pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-B-2)
              (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-3);
              xdefLstHaloCoords(halo-A-1) (halo-A-2) (halo-A-3)
              foreach XX in 1,...,numbervaluehalo
              xdefLstHaloCoordsLstHaloCoordsspace (halo-L-XX)
              xdefLstHaloCoordsLstHaloCoordsspace (halo-B-1) (halo-B-2) (halo-B-3)
              foreach XX in numbervaluehalo,thenumexprnumbervaluehalo-1,...,1
              xdefLstHaloCoordsLstHaloCoordsspace (halo-R-XX)
              ,
              halo/.style=insert path=plot[smooth,samples at=1,...,numbervaluebracep,variable=x]
              (bracep-x),halo/.style=insert path=plot[smooth cycle] coordinates LstHaloCoords ,
              halo pars/.cd,dist/.initial=5pt,step/.initial=2pt
              begindocument
              begintikzpicture
              draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
              draw[dashed,halo];
              endtikzpicture
              enddocument


              The halo path is known to TikZ so it can be used for all sorts of things like intersections or fill with pattern (needs the libraries intersections or patterns), e.g.



              draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
              draw[red,pattern=north west lines,pattern color=blue,halo];


              enter image description here



              As you can see, the result is not perfect, but can be improved by playing with the step parameter (I chose this on purpose in order not to deceive users). An automatically nice solution that works with much more complicated, in particular self-intersecting, paths is much harder to obtain. However, the above works with curves, too, i.e. not just with straight lines.




              Note also that if I only take your dashed contour, add rounded corners and replace the last coordinate by cycle (so that the last corner is also rounded), I get



              enter image description here



              documentclass[tikz,border=3.14mm]standalone
              begindocument
              begintikzpicture
              draw [thick] (1,1) -- (2,2);
              draw [thick] (2,2) -- (2,3.5);
              draw [dashed,rounded corners] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) --
              (0.8,1) -- (1.1,0.8) -- cycle;
              endtikzpicture
              enddocument


              Things look arguably even better if one draws the fist line in one stretch and takes into account the slope of the lower leg when drawing the contour.



              documentclass[tikz,border=3.14mm]standalone
              begindocument
              begintikzpicture
              draw [thick] (1,1) -- (2,2) -- (2,3.5);
              draw [dashed,rounded corners] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
              (0.8,1) -- (1.1,0.8) -- cycle;
              endtikzpicture
              enddocument


              enter image description here



              If you want the dash pattern to close, use



              documentclass[tikz,border=3.14mm]standalone
              usetikzlibrarydecorations.markings
              begindocument
              begintikzpicture
              draw [thick] (1,1) -- (2,2) -- (2,3.5);
              path [rounded corners,preaction=decorate,decoration=markings,mark=at position 0 with %
              pgfmathsetmacromyonpgfdecoratedpathlength/50
              xdefmyonmyon,postaction=draw,dash pattern=on myon pt off myon pt] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
              (0.8,1) -- (1.1,0.8) -- cycle;
              endtikzpicture
              enddocument


              enter image description here






              share|improve this answer





























                3














                The following draws halos around simple paths as the one above. You only need to record the path



                draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);


                and then can draw a halo via



                draw[dashed,halo];


                enter image description here



                documentclass[tikz,border=3.14mm]standalone
                usetikzlibrarydecorations.markings
                newcounterhalo
                tikzsetrecord path/.style=/utils/exec=tikzsethalo pars/.cd,#1,
                decorate,decoration=markings,mark=at position 0 with
                setcounterhalo1%typeoutpgfdecoratedpathlength
                path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-1)
                (-pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-A-2)
                (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-3);
                pgfmathsetmacromystep(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/int(1+(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/pgfkeysvalueof/tikz/halo pars/step)
                xdefmystepmystep,
                mark=between positions pgfkeysvalueof/tikz/halo pars/step and pgfdecoratedpathlength-pgfkeysvalueof/tikz/halo pars/step step mystep pt with stepcounterhalo
                path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo);,
                mark=at position 1 with stepcounterhalo
                path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-1)
                (pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-B-2)
                (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-3);
                xdefLstHaloCoords(halo-A-1) (halo-A-2) (halo-A-3)
                foreach XX in 1,...,numbervaluehalo
                xdefLstHaloCoordsLstHaloCoordsspace (halo-L-XX)
                xdefLstHaloCoordsLstHaloCoordsspace (halo-B-1) (halo-B-2) (halo-B-3)
                foreach XX in numbervaluehalo,thenumexprnumbervaluehalo-1,...,1
                xdefLstHaloCoordsLstHaloCoordsspace (halo-R-XX)
                ,
                halo/.style=insert path=plot[smooth,samples at=1,...,numbervaluebracep,variable=x]
                (bracep-x),halo/.style=insert path=plot[smooth cycle] coordinates LstHaloCoords ,
                halo pars/.cd,dist/.initial=5pt,step/.initial=2pt
                begindocument
                begintikzpicture
                draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                draw[dashed,halo];
                endtikzpicture
                enddocument


                The halo path is known to TikZ so it can be used for all sorts of things like intersections or fill with pattern (needs the libraries intersections or patterns), e.g.



                draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                draw[red,pattern=north west lines,pattern color=blue,halo];


                enter image description here



                As you can see, the result is not perfect, but can be improved by playing with the step parameter (I chose this on purpose in order not to deceive users). An automatically nice solution that works with much more complicated, in particular self-intersecting, paths is much harder to obtain. However, the above works with curves, too, i.e. not just with straight lines.




                Note also that if I only take your dashed contour, add rounded corners and replace the last coordinate by cycle (so that the last corner is also rounded), I get



                enter image description here



                documentclass[tikz,border=3.14mm]standalone
                begindocument
                begintikzpicture
                draw [thick] (1,1) -- (2,2);
                draw [thick] (2,2) -- (2,3.5);
                draw [dashed,rounded corners] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) --
                (0.8,1) -- (1.1,0.8) -- cycle;
                endtikzpicture
                enddocument


                Things look arguably even better if one draws the fist line in one stretch and takes into account the slope of the lower leg when drawing the contour.



                documentclass[tikz,border=3.14mm]standalone
                begindocument
                begintikzpicture
                draw [thick] (1,1) -- (2,2) -- (2,3.5);
                draw [dashed,rounded corners] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                (0.8,1) -- (1.1,0.8) -- cycle;
                endtikzpicture
                enddocument


                enter image description here



                If you want the dash pattern to close, use



                documentclass[tikz,border=3.14mm]standalone
                usetikzlibrarydecorations.markings
                begindocument
                begintikzpicture
                draw [thick] (1,1) -- (2,2) -- (2,3.5);
                path [rounded corners,preaction=decorate,decoration=markings,mark=at position 0 with %
                pgfmathsetmacromyonpgfdecoratedpathlength/50
                xdefmyonmyon,postaction=draw,dash pattern=on myon pt off myon pt] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                (0.8,1) -- (1.1,0.8) -- cycle;
                endtikzpicture
                enddocument


                enter image description here






                share|improve this answer



























                  3












                  3








                  3







                  The following draws halos around simple paths as the one above. You only need to record the path



                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);


                  and then can draw a halo via



                  draw[dashed,halo];


                  enter image description here



                  documentclass[tikz,border=3.14mm]standalone
                  usetikzlibrarydecorations.markings
                  newcounterhalo
                  tikzsetrecord path/.style=/utils/exec=tikzsethalo pars/.cd,#1,
                  decorate,decoration=markings,mark=at position 0 with
                  setcounterhalo1%typeoutpgfdecoratedpathlength
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                  (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-1)
                  (-pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-A-2)
                  (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-3);
                  pgfmathsetmacromystep(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/int(1+(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/pgfkeysvalueof/tikz/halo pars/step)
                  xdefmystepmystep,
                  mark=between positions pgfkeysvalueof/tikz/halo pars/step and pgfdecoratedpathlength-pgfkeysvalueof/tikz/halo pars/step step mystep pt with stepcounterhalo
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo);,
                  mark=at position 1 with stepcounterhalo
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                  (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-1)
                  (pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-B-2)
                  (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-3);
                  xdefLstHaloCoords(halo-A-1) (halo-A-2) (halo-A-3)
                  foreach XX in 1,...,numbervaluehalo
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-L-XX)
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-B-1) (halo-B-2) (halo-B-3)
                  foreach XX in numbervaluehalo,thenumexprnumbervaluehalo-1,...,1
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-R-XX)
                  ,
                  halo/.style=insert path=plot[smooth,samples at=1,...,numbervaluebracep,variable=x]
                  (bracep-x),halo/.style=insert path=plot[smooth cycle] coordinates LstHaloCoords ,
                  halo pars/.cd,dist/.initial=5pt,step/.initial=2pt
                  begindocument
                  begintikzpicture
                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                  draw[dashed,halo];
                  endtikzpicture
                  enddocument


                  The halo path is known to TikZ so it can be used for all sorts of things like intersections or fill with pattern (needs the libraries intersections or patterns), e.g.



                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                  draw[red,pattern=north west lines,pattern color=blue,halo];


                  enter image description here



                  As you can see, the result is not perfect, but can be improved by playing with the step parameter (I chose this on purpose in order not to deceive users). An automatically nice solution that works with much more complicated, in particular self-intersecting, paths is much harder to obtain. However, the above works with curves, too, i.e. not just with straight lines.




                  Note also that if I only take your dashed contour, add rounded corners and replace the last coordinate by cycle (so that the last corner is also rounded), I get



                  enter image description here



                  documentclass[tikz,border=3.14mm]standalone
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2);
                  draw [thick] (2,2) -- (2,3.5);
                  draw [dashed,rounded corners] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  Things look arguably even better if one draws the fist line in one stretch and takes into account the slope of the lower leg when drawing the contour.



                  documentclass[tikz,border=3.14mm]standalone
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2) -- (2,3.5);
                  draw [dashed,rounded corners] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  enter image description here



                  If you want the dash pattern to close, use



                  documentclass[tikz,border=3.14mm]standalone
                  usetikzlibrarydecorations.markings
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2) -- (2,3.5);
                  path [rounded corners,preaction=decorate,decoration=markings,mark=at position 0 with %
                  pgfmathsetmacromyonpgfdecoratedpathlength/50
                  xdefmyonmyon,postaction=draw,dash pattern=on myon pt off myon pt] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  enter image description here






                  share|improve this answer















                  The following draws halos around simple paths as the one above. You only need to record the path



                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);


                  and then can draw a halo via



                  draw[dashed,halo];


                  enter image description here



                  documentclass[tikz,border=3.14mm]standalone
                  usetikzlibrarydecorations.markings
                  newcounterhalo
                  tikzsetrecord path/.style=/utils/exec=tikzsethalo pars/.cd,#1,
                  decorate,decoration=markings,mark=at position 0 with
                  setcounterhalo1%typeoutpgfdecoratedpathlength
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                  (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-1)
                  (-pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-A-2)
                  (-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-A-3);
                  pgfmathsetmacromystep(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/int(1+(pgfdecoratedpathlength-2*pgfkeysvalueof/tikz/halo pars/step)/pgfkeysvalueof/tikz/halo pars/step)
                  xdefmystepmystep,
                  mark=between positions pgfkeysvalueof/tikz/halo pars/step and pgfdecoratedpathlength-pgfkeysvalueof/tikz/halo pars/step step mystep pt with stepcounterhalo
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo);,
                  mark=at position 1 with stepcounterhalo
                  path (0pt,pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-L-numbervaluehalo)
                  (0pt,-1*pgfkeysvalueof/tikz/halo pars/dist) coordinate (halo-R-numbervaluehalo)
                  (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-1)
                  (pgfkeysvalueof/tikz/halo pars/dist,0pt) coordinate (halo-B-2)
                  (pgfkeysvalueof/tikz/halo pars/dist/sqrt(2),-pgfkeysvalueof/tikz/halo pars/dist/sqrt(2)) coordinate (halo-B-3);
                  xdefLstHaloCoords(halo-A-1) (halo-A-2) (halo-A-3)
                  foreach XX in 1,...,numbervaluehalo
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-L-XX)
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-B-1) (halo-B-2) (halo-B-3)
                  foreach XX in numbervaluehalo,thenumexprnumbervaluehalo-1,...,1
                  xdefLstHaloCoordsLstHaloCoordsspace (halo-R-XX)
                  ,
                  halo/.style=insert path=plot[smooth,samples at=1,...,numbervaluebracep,variable=x]
                  (bracep-x),halo/.style=insert path=plot[smooth cycle] coordinates LstHaloCoords ,
                  halo pars/.cd,dist/.initial=5pt,step/.initial=2pt
                  begindocument
                  begintikzpicture
                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                  draw[dashed,halo];
                  endtikzpicture
                  enddocument


                  The halo path is known to TikZ so it can be used for all sorts of things like intersections or fill with pattern (needs the libraries intersections or patterns), e.g.



                  draw[thick,postaction=record path=step=5pt] (1,1) -- (2,2) -- (2,3.5);
                  draw[red,pattern=north west lines,pattern color=blue,halo];


                  enter image description here



                  As you can see, the result is not perfect, but can be improved by playing with the step parameter (I chose this on purpose in order not to deceive users). An automatically nice solution that works with much more complicated, in particular self-intersecting, paths is much harder to obtain. However, the above works with curves, too, i.e. not just with straight lines.




                  Note also that if I only take your dashed contour, add rounded corners and replace the last coordinate by cycle (so that the last corner is also rounded), I get



                  enter image description here



                  documentclass[tikz,border=3.14mm]standalone
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2);
                  draw [thick] (2,2) -- (2,3.5);
                  draw [dashed,rounded corners] (2.2,2) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  Things look arguably even better if one draws the fist line in one stretch and takes into account the slope of the lower leg when drawing the contour.



                  documentclass[tikz,border=3.14mm]standalone
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2) -- (2,3.5);
                  draw [dashed,rounded corners] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  enter image description here



                  If you want the dash pattern to close, use



                  documentclass[tikz,border=3.14mm]standalone
                  usetikzlibrarydecorations.markings
                  begindocument
                  begintikzpicture
                  draw [thick] (1,1) -- (2,2) -- (2,3.5);
                  path [rounded corners,preaction=decorate,decoration=markings,mark=at position 0 with %
                  pgfmathsetmacromyonpgfdecoratedpathlength/50
                  xdefmyonmyon,postaction=draw,dash pattern=on myon pt off myon pt] (2.2,1.9) -- (2.2,3.7) -- (1.8,3.7) -- (1.8,2.1) --
                  (0.8,1) -- (1.1,0.8) -- cycle;
                  endtikzpicture
                  enddocument


                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 10 at 23:22

























                  answered Jun 10 at 16:02









                  marmotmarmot

                  136k6177326




                  136k6177326




















                      doe is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      doe is a new contributor. Be nice, and check out our Code of Conduct.












                      doe is a new contributor. Be nice, and check out our Code of Conduct.











                      doe is a new contributor. Be nice, and check out our Code of Conduct.














                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f495067%2fdashed-trajectory-encircling-two-segments%23new-answer', 'question_page');

                      );

                      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







                      Popular posts from this blog

                      Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                      Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                      Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림