2

I've created this image and I would like to change the black line into a three-colored line (red, white, green). Is there a simple way to obtain this?

enter image description here


Editing after seeing first answer

I was thinking more to something like this:

enter image description here

   \documentclass{standalone}
    \usepackage{tikz}
\usetikzlibrary{patterns,arrows.meta}
\begin{document}

\begin{tikzpicture}


     \filldraw[, fill=orange,line width=9pt, rounded corners] (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6,0) -- (10,0) -- cycle;

\filldraw[line width=9pt, rounded corners]  (5,4.91) -- (6.4,-2);




\end{tikzpicture}

\end{document}

Thank you all: you are something like tikz-artist!

I've modified your code, and I like this one:

\begin{tikzpicture}
\fill[white, rounded corners] (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6,0) -- cycle;
\begin{scope}[even odd rule]
\clip[rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2) -- ([turn]0:1) -| (11,0) -- cycle;
\draw[green!80!black, line width=70pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{scope}
\begin{scope}[even odd rule]
\clip[rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2) -- ([turn]0:1) -| (11,0) -- cycle (-1,-3) rectangle (11,7);
\draw[red, line width=70pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{scope}
\draw[white, line width=20pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{tikzpicture}

enter image description here

Unfortunately, with this size, the edges of the image are cut off - how can I avoid this?

Frank
  • 421
  • 2
    It's not clear what you want: like a line formed by three parallel colored lines, or a line that starts red, then becomes white, then green? – Rmano Feb 21 '22 at 09:06
  • So you like my answer and is using it in a new question. A bit strange that you accept an other answer that does not work with your rounded corners!? – hpekristiansen Mar 01 '22 at 08:17

3 Answers3

4

Is that what you want?

enter image description here

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[rounded corners]
\def\mycurve{(0,0) -- (1,5) -- (3,6) -- (5,5) -- (6,0) -- (10,0) -- cycle}
\draw[red,fill=orange,line width=12pt] \mycurve;
\draw[white,line width=6pt] \mycurve;
\draw[green,line width=2pt] \mycurve;
\end{tikzpicture}
\end{document}
Black Mild
  • 17,569
4
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[orange, rounded corners] (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6,0) -- cycle;
\begin{scope}[even odd rule]
\clip[rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2) -- ([turn]0:1) -| (11,0) -- cycle;
\draw[green!80!black, line width=9pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{scope}
\begin{scope}[even odd rule]
\clip[rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2) -- ([turn]0:1) -| (11,0) -- cycle (-1,-3) rectangle (11,7);
\draw[red, line width=9pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{scope}
\draw[white, line width=3pt, rounded corners] (10,0) -- (0,0) -- (1,5) -- (3,6) -- (5,5) -- (6.4,-2);
\end{tikzpicture}
\end{document}

Orange shape with tricolor border

4

Here is another way that I obtained searching the site, see the answer to something similar here where I got the code from Mark Wibrow and some other more complicated one in this post, the result is somewhat satisfactory but not optimal since a good result is not obtained in the curves.

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=10pt]{standalone}

\usetikzlibrary{decorations} \definecolor{green1}{HTML}{F9130F} \definecolor{red1}{HTML}{13A66A}

%this code is from Mark Wibrow in https://tex.stackexchange.com/a/103088/154390 [start] \def\pgfdecoratedcontourdistance{0pt}

\pgfkeys{/pgf/decoration/contour distance/.code={% \pgfmathparse{#1}% \let\pgfdecoratedcontourdistance=\pgfmathresult}% }

\pgfdeclaredecoration{contour lineto}{start} { \state{start}[next state=draw, width=0pt]{ \pgfpathmoveto{\pgfpoint{0pt}{\pgfdecoratedcontourdistance}}% } \state{draw}[next state=draw, width=\pgfdecoratedinputsegmentlength]{
\pgfmathparse{-\pgfdecoratedcontourdistance*cot(-\pgfdecoratedangletonextinputsegment/2+90)}% \let\shorten=\pgfmathresult% \pgfpathlineto{\pgfpoint{\pgfdecoratedinputsegmentlength+\shorten}{\pgfdecoratedcontourdistance}}%
} \state{final}{ \pgfpathlineto{\pgfpoint{\pgfdecoratedinputsegmentlength}{\pgfdecoratedcontourdistance}}% }
} %this code is from Mark Wibrow in https://tex.stackexchange.com/a/103088/154390 [end]

\begin{document}

\begin{tikzpicture}[
    EmbRibbon/.style={%Embellishment ribbon
        draw=none,
        rounded corners=5pt,
        line join=round,
        line cap=rect,
        postaction={
            decoration={contour lineto, contour distance=-10pt},
            draw=green1,line width=10pt, decorate},
        postaction={
            decoration={contour lineto, contour distance=10pt}, 
            draw=red1, line width=10pt, decorate},
        postaction={
            decoration={contour lineto, contour distance=0pt}, 
            draw=white, line width=10pt, decorate},
        postaction={
            decoration={contour lineto, contour distance=13pt}, 
            draw=white, line width=1pt,densely dashed,opacity=0.5, decorate}
    }
]       
\draw [EmbRibbon,fill=orange] 
(0,0) 
    -- ++(-9,0) 
    -- ++(1,5) 
    -- ++(2,1) 
    -- ++(2,-1) 
    -- ++(1,-5) coordinate (temp);
\draw [EmbRibbon] 
(temp)++(-0.43,2.5)
    -- ++(1,-5);    

\end{tikzpicture}   

\end{document}

J Leon V.
  • 11,533
  • 16
  • 47