3

I have this tikzpicture:

\documentclass[10pt]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw[line width=0.5cm] (10cm,1cm)--(12cm,1cm) arc(90:-90:1.3cm and 0.943cm) --(10cm,-0.885cm);
\end{tikzpicture}

\end{document}

Figure with unmodified width

Is there any way to get to this?:

Figure with modified width

That is, the thickness of the arch decreases as it goes down (even if the lower horizontal line has the same thickness as the end of the arch).

Thanks!

manooooh
  • 3,203
  • 2
  • 21
  • 46

2 Answers2

5

enter image description here

\documentclass[10pt]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \draw[fill] (10cm,1cm)--
(12cm,1cm) arc(90:-90:1.3cm and 0.943cm) --
(10cm,-0.885cm) --
(10cm,-1.1cm) --
(12cm,-1.1cm)  arc(-90:90:1.5cm and 1.3cm) --
(10cm, 1.5cm) 
;
\end{tikzpicture}

\end{document}
David Carlisle
  • 757,742
  • Oh, an answer from David!! I thought there was some parameter of the arc command that made the end less thick, but it seems that it is not. I sensed it because I find it hard to see all the parts that make up the figure haha, but I will pay attention. Thanks! – manooooh Jan 31 '18 at 21:10
  • @manooooh it's possible that you could play with the decorations library to draw each path segment a slightly narrower width, but filling the final outline more likely to give smoother result although you have to draw the outline "by hand" – David Carlisle Jan 31 '18 at 21:12
  • How can I do the same but with the difference that, looking superiorly, the figure starts with the thin arc, and ends with the thick line, besides enlarging the arc so there is a little more distance between the horizontal lines? (Lengthening the arch creates more distance). I have a mess in my head with so many parts :(. Thanks – manooooh Jan 31 '18 at 22:10
  • @manooooh I am not sure I understood the comment, for testing , change fill back to line width=0.5mm or something and draw the outline, when you are happy with it change it back to fill – David Carlisle Jan 31 '18 at 22:48
  • Sometimes I express myself badly... Apologies. Now I realize that I simply want to rotate the figure vertically. I added as parameter rotate=180 to the draw command (\draw[fill,rotate=180]...), but I need that the figure points towards the left side, and not the right, as it does the 180 degrees. – manooooh Jan 31 '18 at 23:12
  • I answer to myself. I could get adding \reflectbox{...}. – manooooh Feb 01 '18 at 00:08
  • 1
    @manooooh why draw it one way then reflect? you could just negate all the x coordinates and draw it in the other direction. – David Carlisle Feb 01 '18 at 07:57
1

I could not refrain from resurrecting an old trick by Alain Matthes.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}

\makeatletter
%from https://tex.stackexchange.com/a/14295/121799
\pgfkeys{/pgf/decoration/.cd,
         start color/.store in =\startcolor,
         end color/.store in   =\endcolor,
         vertical decrease slope/.store in = \DrasticY,
         color slope/.store in = \ColorSensitivity
}

\pgfdeclaredecoration{vertical width and color change}{initial}{
 \state{initial}[width=0pt, next state=line, persistent precomputation={%
   \pgfmathdivide{50}{\pgfdecoratedpathlength}%
   \let\increment=\pgfmathresult%
   \pgfmathsetmacro{\orilinewidth}{\pgflinewidth}%
   \pgfmathsetmacro{\ynod}{\pgf@y}%
   \def\x{0}%
 }]{}
 \state{line}[width=.5pt,   persistent postcomputation={%
     \pgfmathsetmacro{\x}{\the\pgf@y-\ynod}%
   }]{%
   \pgfmathsetmacro{\newlinewidth}{max(\DrasticY*\x*0.075pt+\orilinewidth,0)}%
   \pgfsetlinewidth{\newlinewidth}
   \pgfsetarrows{-}%
   \pgfpathmoveto{\pgfpointorigin}%
   \pgfpathlineto{\pgfqpoint{.75pt}{0pt}}%
    \pgfmathtruncatemacro{\absx}{round(100*(1-min(max(\ColorSensitivity*(\x+28),0),1)))}
   \pgfsetstrokecolor{\endcolor!\absx!\startcolor}%
   \pgfusepath{stroke}%
 }
 \state{final}{%
   \pgfsetlinewidth{\pgflinewidth}%
   \pgfpathmoveto{\pgfpointorigin}%
    \pgfmathtruncatemacro{\absx}{round(100*(1-min(max(\ColorSensitivity*(\x+28),0),1)))}
   \color{\endcolor!\absx!\startcolor}%
   \pgfusepath{stroke}% 
 }
}

\makeatother

\begin{tikzpicture}
  \begin{scope}
    \draw[ line width=0.5cm, decoration={vertical width and color change,   
start color=black, end color=black,vertical decrease slope=0.8,color slope=0.025}, decorate] (10cm,1cm) -- (12cm,1cm) 
     arc(90:-90:1.3cm and 0.943cm) 
    to (10cm,-0.885cm);
 \end{scope}
 \begin{scope}[xshift=5cm]
    \draw[ line width=0.5cm, decoration={vertical width and color change,   
start color=blue, end color=black,vertical decrease slope=3.8,color slope=0.02}, decorate] (10cm,1cm) -- (12cm,1cm) 
     arc(90:-90:1.3cm and 0.943cm) 
    to (10cm,-0.885cm);
 \end{scope}
\end{tikzpicture}
\end{document}

One can control the amount by which the line width decreases by adjusting vertical decrease slope and one may even play with the color.

enter image description here

  • ooh decorations: https://tex.stackexchange.com/questions/413076/how-to-reduce-the-width-of-a-composite-figure-with-the-command-arc-and-a-line-in/413083?noredirect=1#comment1031412_413083 – David Carlisle Jan 31 '18 at 23:16