3

I have a litle trouble with the "even odd rule". I would like to draw the picture below which isn't the problem. The problem is, that i would need to have the little white spots, where the "hobby-line" cuts itselfs out, also to have the pattern.

I am working with the code below.

Please excuse the complicated definition of the coordinates, but this is part of a bigger picture and it was much easier to just make it work on its own then writing it independently.

If you have any questions about things you need to know please ask :)

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, patterns, hobby}

\begin{document}
    \begin{tikzpicture}[scale=1, use Hobby shortcut]
        \def \abstand {1}

        \coordinate (Anfang Kurve) at (0,0);

        \coordinate (H1) at ($(Anfang Kurve) + (0.5*\abstand, 0.2*\abstand)$);
        \coordinate (H2) at ($(H1) + (1*\abstand, -0.15*\abstand)$);
        \coordinate (H3) at ($(H2) + (0.75*\abstand, 2.35*\abstand)$);
        \coordinate (H4) at ($(H3) + (0.4*\abstand, -2*\abstand)$);
        \coordinate (H5) at ($(H4) + (0.1*\abstand, -1.2*\abstand)$);
        \coordinate (H6) at ($(H5) + (-0.75*\abstand, 0.4*\abstand)$);
        \coordinate (H7) at ($(H6) + (-0.4*\abstand, 0.5*\abstand)$);
        \coordinate (H8) at ($(H7) + (-0.8*\abstand, 0.1*\abstand)$);

        \draw[pattern = north west lines, even odd rule] (Anfang Kurve) .. (H1) .. (H2) 
            .. (H3) .. (H4) .. (H5) .. (H6) .. (H7) .. (H8) .. (Anfang Kurve)
        (Anfang Kurve) --+ (2*\abstand, 0) --+(2*\abstand,2*\abstand) 
            --+ (3*\abstand, 2*\abstand) --+ (3*\abstand, -1*\abstand) 
            --+ (\abstand, -1*\abstand) --+ (\abstand,0) --+ (0,0);
    \end{tikzpicture}
\end{document}

result of the text above areas with the problem

Thanks in advands for any kind of help. :)

7
  • If I understood correctly, you would like the inside of the areas you have surrounded in red to be filled with the same pattern (north-east lines). Is that it? – AndréC Aug 19 '19 at 10:53
  • Thats exactly what I want – Kai Aug 19 '19 at 10:59
  • Ok, please make your code compileable. – AndréC Aug 19 '19 at 11:06
  • and done, please excuse the time it took. I hade quite some other work to do – Kai Aug 19 '19 at 18:36
  • The small white spots are irrespective of even odd rule, i.e. they stay even if you drop that key. Please consider tagging your question tikz-pgf such that it gets more attention. – user194703 Aug 19 '19 at 18:57
4

The problem you encounter has nothing to do with even odd rule, i.e. the small white spots will remain if you drop the key. One way to solve the issue is to employ the pgfplots fillbetween library.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc,hobby,patterns}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}[scale=1, use Hobby shortcut]
    \def \abstand {1}

    \coordinate (Anfang Kurve) at (0,0);

    \coordinate (H1) at ($(Anfang Kurve) + (0.5*\abstand, 0.2*\abstand)$);
    \coordinate (H2) at ($(H1) + (1*\abstand, -0.15*\abstand)$);
    \coordinate (H3) at ($(H2) + (0.75*\abstand, 2.35*\abstand)$);
    \coordinate (H4) at ($(H3) + (0.4*\abstand, -2*\abstand)$);
    \coordinate (H5) at ($(H4) + (0.1*\abstand, -1.2*\abstand)$);
    \coordinate (H6) at ($(H5) + (-0.75*\abstand, 0.4*\abstand)$);
    \coordinate (H7) at ($(H6) + (-0.4*\abstand, 0.5*\abstand)$);
    \coordinate (H8) at ($(H7) + (-0.8*\abstand, 0.1*\abstand)$);
    \draw[pattern = north west lines, even odd rule,name path=curve] 
    (Anfang Kurve) .. (H1) .. (H2) 
            .. (H3) .. (H4) .. (H5) .. (H6) .. (H7) .. (H8) .. (Anfang Kurve)
        (Anfang Kurve) --+ (2*\abstand, 0) --+(2*\abstand,2*\abstand) 
            --+ (3*\abstand, 2*\abstand) --+ (3*\abstand, -1*\abstand) 
            --+ (\abstand, -1*\abstand) --+ (\abstand,0) --+ (0,0);
    \path[name path=hori] (Anfang Kurve) --+ (2*\abstand, 0);
    \path[pattern = north west lines,
    intersection segments={of=curve and hori,sequence={A2}}];
\end{tikzpicture}
\end{document}

enter image description here

1
  • that absolutely solves my problem :) thank you very much for your effort and the quick respond :) – Kai Aug 19 '19 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.