行动后和奇偶规则

行动后和奇偶规则

我正在尝试填充多边形两个向内偏移之间的空间。感谢很棒的答案我可以弄清楚如何创建向内的形状。但是,我无法找到使用 填充两条路径之间的区域的方法even odd rule

以下是 MWE:

\documentclass[border=2mm]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{nfold}

\makeatletter
\tikzset{offset/.code=\tikz@addmode{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}}
\makeatother

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
        ymode=log, 
        xmin=0, xmax=200, 
        ymin=1, ymax=10000, 
        grid=both]

    \begin{scope}[even odd rule]
        \fill
    [postaction={offset=-1pt, draw=red}]
    [postaction={offset=-3pt, draw=blue}]
   (axis cs: 52,10000) .. controls (axis cs: 198,207) .. (axis cs: 199,5) -- 
   (axis cs: 159,5) .. controls (axis cs: 159,166) .. (axis cs: 50,5371) -- cycle;
    \end{scope}
   
    \end{axis}
    \end{tikzpicture}

\end{document}

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{nfold}
\makeatletter
\tikzset{offset/.code=\tikz@addmode{\pgfgetpath\tikz@temp\pgfsetpath\pgfutil@empty\pgfoffsetpath\tikz@temp{#1}}}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymode=log, 
xmin=0, xmax=200, 
ymin=1, ymax=10000, 
grid=both,
]
\draw[save path=\mypath](52,10000) .. controls (198,207) .. (199,5) -- (159,5) .. controls (159,166) .. (50,5371) -- cycle;
\draw[red, thick, use path=\mypath, offset=-1pt, save path=\mypathA];
\draw[blue, thick, use path=\mypath, offset=-3pt, save path=\mypathB];
\fill[even odd rule, use path=\mypathA \mypathB];
\end{axis}
\end{tikzpicture}
\end{document}

具有环形和填充区域的图形

相关内容