TikZ 具有連續對角線的雙色填滿圖案

TikZ 具有連續對角線的雙色填滿圖案

我正在嘗試創建(在背面)帶有連續對角線的雙色填充圖案。我已經複製了大部分程式碼這裡(非常感謝 stackexchange 社群)。但是,我的結果如下所示:
花俏的圖案,但不是我的期望

\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[
     Pattern/.style = {pattern=north east hatch,
                    pattern color=yellow,
                    hatch distance=10pt, 
                    hatch thickness=4pt},
  ]

  \coordinate (o) at (0,0);

  \makeatletter
\tikzset{
        hatch distance/.store in=\hatchdistance,
        hatch distance=5pt,
        hatch thickness/.store in=\hatchthickness,
        hatch thickness=5pt
        }
\pgfdeclarepatternformonly[\hatchdistance,\hatchthickness]{north east hatch}% name
    {\pgfqpoint{-1pt}{-1pt}}% below left
    {\pgfqpoint{\hatchdistance}{\hatchdistance}}% above right
    {\pgfpoint{\hatchdistance-1pt}{\hatchdistance-1pt}}%
    {
        \pgfsetcolor{\tikz@pattern@color}
        \pgfsetlinewidth{\hatchthickness}
        \pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
        \pgfpathlineto{\pgfqpoint{\hatchdistance}{\hatchdistance}}
        \pgfusepath{stroke}
    }
\makeatother
  
 
 \draw[preaction={fill=green}, Pattern] (o) 
    -- ++(1,0) 
    -- ++(0,-1) 
    -- ++(-1,0) 
    --cycle;

\end{tikzpicture}
\end{document}

線路上有一些凹凸。我的程式碼出了什麼問題?我怎麼才能去除這個腫塊。預先感謝您的任何幫助!

更新 19:03h:我使用 Acrobat Reader、SumatraPDF 和 Firefox 進行查看,但是,在所有情況下都會出現類似的問題。

答案1

透過使用patterns.meta庫,結果比使用庫好得多patterns(但對於扒手來說仍然不完美):

在此輸入影像描述

至少,程式碼要簡單得多:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{patterns.meta}

\begin{document}
    \begin{tikzpicture}
\path[fill=green,
      postaction={pattern={Lines[angle=45,distance={6pt},line width=3pt]},
                  pattern color=yellow},
      postaction={draw, semithick}]
     (0,0) rectangle (1,1);
  \end{tikzpicture}
\end{document}

相關內容