The goal is to try and draw a coil with a rectangular bend at its start and end, all in one path
/draw
command, like this:
The coil itself is a horizontal path, and the endings go down vertically from both ends, i.e. in a 90 degree angle.
However, while the start works, the end does not, despite the base path (green) forming the correct shape:
with code
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{
decorations.pathmorphing,
arrows
}
\begin{document}
\begin{tikzpicture}[
thiscoil/.style={%
decorate,%
decoration={%
coil,
aspect=0.3,
segment length=0.5em,
amplitude=0.5em,
pre=lineto,
post=lineto,
pre length=1.5em,
post length=1.5em,
},
o-o,
},
thick
]
% Same path, without coil:
\draw[transform canvas={yshift=3em}, green] (0,0) |- ++ (5em,1em) -| ++ (0.5em,-1em);
% A coil with horizontal straight endings:
\draw[thiscoil, blue] (0,0) |- ++ (5em,1em) -| ++ (0.5em,-1em);
% A coild without horizontal endings, only vertical ones:
\draw[thiscoil, transform canvas={yshift=-3em}, red] (0,0) |- ++ (5em,1.5em) -| ++ (0.5em,-1.5em);
\end{tikzpicture}
\end{document}
At best, the coil should look like the left/start of the red example on both ends. If it comes with a horizontal indent into the coil, like the start/left of the blue and end/right of the red path, that is okay, too.
How can this be done?