7

I want to give the impression of a wall, but the diagnals i drew cross each other. I just want them to follow around the corner like pictured on the left link to picture

    \begin{tikzpicture}[
    media/.style={font={\footnotesize\sffamily}},
    wave/.style={
    decorate,decoration={snake,post length=1.4mm,amplitude=2mm,
    segment length=2mm},thick},
    interface/.style={
% The border decoration is a path replacing decorator. 
% For the interface style we want to draw the original path.
% The postaction option is therefore used to ensure that the
% border decoration is drawn *after* the original path.
       postaction={draw,decorate,decoration={border,angle=-135,
        amplitude=0.2cm,segment length=2mm}}},
    ]
          \draw[black,line width=.5pt,interface,rotate=180](-11,-2)--(0,-2);
    \draw[black,line width=.5pt,interface](0,0)--++(1,0)--++(0,-1)--++          (1,0)--++        (0,1)--++(1,0);

    \end{tikzpicture}
  • I think path decoration is the wrong way to do this -- I think you'll find it easier to define the area of the wall and fill it with a "north west lines" pattern – Thruston Dec 7 '15 at 21:10
  • And also Welcome to TeX.SX!, but please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Thruston Dec 7 '15 at 21:11
6

Here's one approach based on \fill rather than using decorate.

enter image description here

\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns} 
\begin{document}
\begin{tikzpicture}
    \fill[pattern=north east lines] (0,0) -- (1,0) -- (1,-1) -- (2,-1) -- (2,0) -- (3,0) 
    -- (3,-0.12) -- (2.12,-0.12) -- (2.12, -1.12) -- (0.88,-1.12) -- (0.88, -0.12) -- (0,-0.12) -- cycle;
    \draw (0,0) -- (1,0) -- (1,-1) -- (2,-1) -- (2,0) -- (3,0);
\end{tikzpicture}
\end{document}

I am sure there is a more efficient way to do the coordinates of the paths, but at least this gives you the general idea.

  • hey mind your own business .... :P – percusse Dec 7 '15 at 22:01
  • 1
    @percusse ha! ha! you're welcome to have a go at some MP answers! I was going to delete this when one of you grown ups answered it properly :-) – Thruston Dec 7 '15 at 22:13
  • \fill[pattern=north east lines] (0,0) -| (1,-1) -| (2,0) -| (3,-0.12) -| (2.12,-1.12) -| (0.88,-0.12) -| cycle; \draw (0,0) -| (1,-1) -| (2,0) -- (3,0); – cfr Dec 8 '15 at 2:25
0

I think that Thruston's filling answer above gives a neater result and it is faster to compile, and probably easier to construct. However, you can use the border decoration if you wish:

border decoration

I used 2 tricks. First, I drew the path 'backwards'. Second, I clipped it.

\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
  \clip  ([yshift=.2pt]0,0) -| ([xshift=.2pt]1,-1) -| ([yshift=.2pt,xshift=-.2pt]2,0) -| (3,-1.2) -| cycle;
  \draw [preaction={decorate, draw}, decoration={border, angle=45, amplitude=1mm, segment length=.5mm}](3,0) -- (2,0) |- (1,-1) |- (0,0);
\end{tikzpicture}
\end{document}

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.