三色 tikz 线条

三色 tikz 线条

我创建了此图像,我想将黑线改为三色线(红、白、绿)。有没有简单的方法可以实现这一点?

在此处输入图片描述


看到第一个答案后进行编辑

我更多地考虑的是这样的:

在此处输入图片描述

   \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}

谢谢大家:你们就像 tikz-artist 一样!

我修改了你的代码,我喜欢这个:

\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}

在此处输入图片描述

不幸的是,由于这种尺寸,图像的边缘被切断了 - 我该如何避免这种情况?

答案1

\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}

带三色边框的橙色形状

答案2

那是你要的吗?

在此处输入图片描述

\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}

答案3

这是我在网站上搜索到的另一种方法,请参阅我获取代码的类似答案马克·维布罗还有一些更复杂的这个帖子,结果有些令人满意,但不是最佳的,因为在曲线中没有获得好的结果。

结果:

在此处输入图片描述

梅威瑟:

\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}

相关内容