我正在尝试使用 overleaf 创建具有连续对角线的双色填充图案。我复制了大部分代码这里(非常感谢 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}