1

I'm trying to create (with overleaf) a two-color fill pattern with continuous diagonal lines. I have copied most of the code from here (many thanks to the stackexchange community). However, my result looks like this:
Fancy Pattern, however not my expectation

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

There are some bumps on the lines. What's going wrong with my code? How can I remove this bumps. Thanks in advance for any help!

Update 19:03h: I used Acrobat Reader, SumatraPDF, and Firefox for viewing, however, similar artifacts occur in all cases.

Flow
  • 13

1 Answers1

3

By use of patterns.meta library the result is far better than with patterns (but for pickpockets still not perfect):

enter image description here

Ar least, code is much, much simpler:

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

Zarko
  • 296,517
  • +1 strange that the typo (1,) still compiles – hpekristiansen May 05 '22 at 21:55
  • @hpekristiansen, indeed! Thank you to note it. Corrected now. – Zarko May 05 '22 at 23:12
  • @Zarko: Many thanks for that solution. It looks much better than mine. The funny thing is that in Firefox the pattern looks horrible but in Adobe Acrobat it's depitcted like in your solution. – Flow May 06 '22 at 11:10