Here the lines:
I have no idea how to make the little bump. If only it were straight lines :)
Colors are:
- green: #9DC634
- orange: #F39614
- pink: #F39614
- purple: #AB7CB5
Thanks for your help
Here the lines:
I have no idea how to make the little bump. If only it were straight lines :)
Colors are:
Thanks for your help
Update: I' adding a second way to do it.
double line and clips.arcs. Easier this way but not valid for any kind of curve.\documentclass[tikz,border=2mm]{standalone}
\newcommand{\myline}{(0,0) -- (5,0) to[out=0,in=180] (6,0.25) to[out=0,in=180] (7,0) -- (8,0)}
\definecolor{mygreen} {HTML}{9DC634}
\definecolor{myorange}{HTML}{F39614}
\definecolor{mypink} {HTML}{FF00FF} % changed
\definecolor{mypurple}{HTML}{AB7CB5}
\begin{document}
\begin{tikzpicture}
\useasboundingbox (-0.5,-1.5) rectangle (8.5,1);
% first way
\begin{scope}
\clip (0,-1) rectangle (8,1);
\begin{scope}
\clip\myline |- (0,1) --cycle;
\draw[mypurple,double distance=1.5mm-\pgflinewidth] \myline;
\draw[mypink ,double distance=0.5mm-\pgflinewidth] \myline;
\end{scope}
\begin{scope}
\clip\myline |- (0,-1) --cycle;
\draw[mygreen ,double distance=1.5mm-\pgflinewidth] \myline;
\draw[myorange,double distance=0.5mm-\pgflinewidth] \myline;
\end{scope}
\end{scope}
% second way
\begin{scope}[shift={(0,-1)}]
\foreach[count=\ii]\i in {mygreen,myorange,mypink,mypurple}
\draw[draw=\i] (0,0.05\ii) --++ (1,0) arc (270:290:1.5-0.05\ii) arc (110:70:2+0.05\ii)
arc (250:270:1.5-0.05\ii) -- (8,0.05*\ii);
\end{scope}
\end{tikzpicture}
\end{document}
Making Bézier curves parallel isn't a trivial problem. Here's a third hacky approach.
\documentclass[tikz]{standalone}
\begin{document}
\tikz[
very thick,
loo/.style args={#1:#2}{#1 looseness=1.05^\i,#2 looseness=.95^\i}
] \foreach[count=\i]\c in {9DC634, F39614, FFC0CB, AB7CB5}
\color[HTML]{\c}
\draw[yshift=\i mm, out=0, in=180] (0,0) --++(right:3)
to[loo=in:out] ++(2,.5) to[loo=out:in] ++(2,-.5) -- ++(right:1);
\end{document}
You could bend the line a bit:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[rounded corners=0.2cm]
\draw[red] (0,0) -- (5,0) to[bend left=35] (7,0) -- (9,0);
\draw[green,yshift=1mm] (0,0) -- (5,0) to[bend left=35] (7,0) -- (9,0);
\end{tikzpicture}
\end{document}
Just for fun, here're two new approaches both try to avoid parsing the same path multiple times, and both need to manually enlarging bounding boxes.
save path=<macro> and use path=<macro>postaction={<options>}\documentclass[tikz,border=2mm]{standalone}
% taken from Juan Castaño's answer https://tex.stackexchange.com/a/679439
\newcommand{\myline}{(0,0) -- (5,0) to[out=0,in=180] (6,0.25) to[out=0,in=180] (7,0) -- (8,0)}
\definecolor{mygreen} {HTML}{9DC634}
\definecolor{myorange}{HTML}{F39614}
\definecolor{mypink} {HTML}{FF00FF} % changed
\definecolor{mypurple}{HTML}{AB7CB5}
\begin{document}
% using \foreach with option count
% similar to Qrrbrbirlbel's answer https://tex.stackexchange.com/a/679440
\begin{tikzpicture}
\foreach \i[count=\n] in {mygreen, myorange, mypink, mypurple} {
\draw[\i, yshift=3pt*\n] \myline;
}
\end{tikzpicture}
% using save path and use path to accelerate path parsing
% manual bounding box enlarging needed
\begin{tikzpicture}
\path[save path=\mypath] \myline;
\foreach \i[count=\n from 0] in {mygreen, myorange, mypink, mypurple} {
\draw[\i, transform canvas={yshift=3pt*\n}, use path=\mypath];
}
\path (0,.5);
\end{tikzpicture}
% using postaction with transform canvas
% manual bounding box enlarging needed
\begin{tikzpicture}
\draw[
mygreen,
postaction={draw=myorange, transform canvas={yshift=3pt}},
postaction={draw=mypink, transform canvas={yshift=6pt}},
postaction={draw=mypurple, transform canvas={yshift=9pt}}
]
(0,0) -- (5,0) to[out=0,in=180] (6,0.25) to[out=0,in=180] (7,0) -- (8,0);
\path (0,.5);
\end{tikzpicture}
\end{document}
Here is another solution using tikz-nfold, credits to this answer for the colors.
The advantages of this solution include that it works with almost every path, and that the curved parts are all at a constant distance from each other. Disadvantages are that you have to load another library, and that the compile times can be a bit longer.
The interface has gotten simpler with tikz-nfold version 0.1.0:
\usepackage{tikz}
\usetikzlibrary{nfold}
[...]
\begin{tikzpicture}
\path[save path=\mypath]
(0,0) -- (5,0) to[out=0, in=180] (7,.75) to[out=0, in=180] (9,0) -- (10,0);
\pgfsetlinewidth{1pt}
\foreach \mycolor [count=\i] in {9DC634,F39614,FF00FF,AB7CB5}
\definecolor{tempcolor}{HTML}{\mycolor}
\color{tempcolor}
\pgfoffsetpathindex{\mypath}{8pt}{\i}{4}
\pgfusepathqstroke;
\end{tikzpicture}
An interesting approach taken from this nice answer:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\color[HTML]{9DC634}
\draw (0,0) -- (1,0) coordinate (A)
.. controls +(1,0) and +(-1,0) .. (3,1) coordinate (B)
.. controls +(1,0) and +(-1,0) .. (5,0) coordinate (C) -- (6,0);
\path (A) .. controls +(1,0) and +(-1,0) .. (B)
{ \foreach \i in {1,...,40} { coordinate[pos={\i/40}] (p\i) } };
\path (B) .. controls +(1,0) and +(-1,0) .. (C)
{ \foreach \i in {40,...,80} { coordinate[pos={(\i-40)/40}] (p\i) } };
\foreach \d/\c in {1mm/F39614, 2mm/FFC0CB, 3mm/AB7CB5} {
\color[HTML]{\c}
\draw (0,\d) -- ($(p1)!\d!90:(p2)$)
{ \foreach \i [count=\j from 3] in {2,...,79} {-- ($(p\i)!\d!90:(p\j)$) } }
-- ($(p80)!\d!-90:(p79)$) -- (6,\d);
}
\end{tikzpicture}
\end{document}