3

I want to clip the parts of an area such that a path which goes through it proceed at the border of the area. It should look like that but there must be a better solution instead of cutting with that rectangle.

\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\draw   (4,0) node (11) {}
        (2,0.1) node (12) {}
        (4.4,3.2) node (13) {}
        (2,3.6) node (14) {} 
        (4.8,1.3) node (15) {}
        (1.1,1.8) node (16) {} 
        (3.2,1.8) node (17) {}
;

\draw  [line width=0.10mm] plot[smooth, tension=.7] coordinates {(15)(17)(16)};
\draw [fill=black!40, black!40] plot [smooth cycle, tension=.8] coordinates {(3,2.2)(3.6,2.3)(3.7,1.8)(3.5,1.5)(3,1.4)(2.8,1.8)};
\draw  [line width=0.125mm] plot[smooth, tension=.7] coordinates {(11)(17)(14)};
\draw [fill=black!30, black!30] plot [smooth cycle, tension=.8] coordinates {(3.2,2.2)(3.5,2.2)(3.6,1.9)(3.3,1.5)(3,1.5)(2.9,1.8)}; 
\draw  [line width=0.15mm] plot[smooth, tension=.7] coordinates {(12)(17)(13)};  
\draw [fill=black!20, black!20] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)}; 
\clip [rotate=52](3.0653,-1.4084) rectangle (3.7509,-1.6064);
\draw [black!100] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)}; 

\end{tikzpicture}
\end{document}

Edit: I failed to make clear what i want. The solution should work for all 3 path and look like that

enter image description here

1

You could clip according to existing paths/nodes like \clip plot[smooth, tension=.7] coordinates {(12)(17)(13)} -- (15) -- (11) -- cycle; although this is a slightly tighter clipping than would be desired.

enter image description here

With a little bit of manual adjustment (via the TikZ calc library) on the midpoint of the plot we can get a bit closer to a natural clipping with \clip plot[smooth, tension=.7] coordinates {(12)($(17)+(-0.005,0.005)$)(13)} -- (15) -- (11) -- cycle;.

enter image description here

\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1]

\draw   (4,0) node (11) {}
        (2,0.1) node (12) {}
        (4.4,3.2) node (13) {}
        (2,3.6) node (14) {} 
        (4.8,1.3) node (15) {}
        (1.1,1.8) node (16) {} 
        (3.2,1.8) node (17) {}
;
\draw  [line width=0.10mm] plot[smooth, tension=.7] coordinates {(15)(17)(16)};
\draw [fill=black!40, black!40] plot [smooth cycle, tension=.8] coordinates {(3,2.2)(3.6,2.3)(3.7,1.8)(3.5,1.5)(3,1.4)(2.8,1.8)};
\draw  [line width=0.125mm] plot[smooth, tension=.7] coordinates {(11)(17)(14)};
\draw [fill=black!30, black!30] plot [smooth cycle, tension=.8] coordinates {(3.2,2.2)(3.5,2.2)(3.6,1.9)(3.3,1.5)(3,1.5)(2.9,1.8)}; 
\draw  [line width=0.15mm] plot[smooth, tension=.7] coordinates {(12)(17)(13)};  
\draw [fill=black!20, black!20] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)}; 
\clip  plot[smooth, tension=.7] coordinates {(12)($(17)+(-0.005,0.005)$)(13)} -- (15) -- (11) -- cycle;
\draw [black!100] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)}; 

\end{tikzpicture}
\end{document}

Applying this to all the crossing paths requires appropriate scoping of the different \clips.

enter image description here

\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=1]

\draw   (4,0) node (11) {}
        (2,0.1) node (12) {}
        (4.4,3.2) node (13) {}
        (2,3.6) node (14) {} 
        (4.8,1.3) node (15) {}
        (1.1,1.8) node (16) {} 
        (3.2,1.8) node (17) {}
;

\draw  [line width=0.10mm] plot[smooth, tension=.7] coordinates {(15)(17)(16)};
\draw [fill=black!40, black!40] plot [smooth cycle, tension=.8] coordinates {(3,2.2)(3.6,2.3)(3.7,1.8)(3.5,1.5)(3,1.4)(2.8,1.8)};
\draw  [line width=0.125mm] plot[smooth, tension=.7] coordinates {(11)(17)(14)};
\draw [fill=black!30, black!30] plot [smooth cycle, tension=.8] coordinates {(3.2,2.2)(3.5,2.2)(3.6,1.9)(3.3,1.5)(3,1.5)(2.9,1.8)};
\draw  [line width=0.15mm] plot[smooth, tension=.7] coordinates {(12)(17)(13)}; 
\draw [fill=black!20, black!20] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)}; 

\begin{scope}
\clip plot[smooth, tension=.7] coordinates {(15)($(17)+(0,-0.005)$)(16)} -- (13) -- cycle;
\draw [black!100] plot [smooth cycle, tension=.8] coordinates {(3,2.2)(3.6,2.3)(3.7,1.8)(3.5,1.5)(3,1.4)(2.8,1.8)};
\end{scope}

\begin{scope}
\clip plot[smooth, tension=.7] coordinates {(11)($(17)+(-0.005,-0.005)$)(14)} -- (13) -- (15) -- cycle;
\draw [black!100] plot [smooth cycle, tension=.8] coordinates {(3.2,2.2)(3.5,2.2)(3.6,1.9)(3.3,1.5)(3,1.5)(2.9,1.8)}; 
\end{scope}

\begin{scope}
\clip  plot[smooth, tension=.7] coordinates {(12)($(17)+(-0.005,0.005)$)(13)} -- (15) -- (11) -- cycle;
\draw [black!100] plot [smooth cycle, tension=.8] coordinates {(3.2,2)(3.4,2.1)(3.4,1.8)(3.2,1.6)(3.0245,1.579)(3,1.8)};
\end{scope}

\end{tikzpicture}
\end{document}
| improve this answer | |
  • It work for 1 but if I try it like that for all 3 path I can't get it work. I didn't make it clear that it should work for all path but I edited my question now. – jigsawl Jun 6 '17 at 18:37
  • @jigsawl Probably that's due to \clip affecting everything in the same scope as itself. – Dai Bowen Jun 6 '17 at 19:15

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.