Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This might be a tikz newbie question but I have some trouble solving this.

I want to draw and fill a rectangular path where path morphing should be applied only to the upper side of the shape, more specifically I want to have an upper part with random steps. The rest of the path (left, lower and right sides) should just be straight lines. The shape should be closed and filled with one color.

My problem is that I cannot figure out how to apply the morphing only to the upper side and I suppose I cannot break up the path into different subpaths since I want to fill the final shape. Is there a way to use the morphing only on a part of the full path? Another problem is that the cycle command does not really close the shape at the upper left corner.

I tried to find a solution in the tikz manual but there was nothing that really helped me.

Here is some example code:

\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}

\begin{document}

\usetikzlibrary{decorations.pathmorphing}
\begin{tikzpicture}

\draw[decorate, decoration={random steps,segment length=3.0mm, amplitude=2.0mm}, thick, rounded corners=1ex, fill=brown!70] (0,0) -- (4,0) -- ++(0, -1) -- ++(-4,0) -- cycle;


\end{tikzpicture}
\end{document}
share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Kurt Nov 1 '12 at 14:07

1 Answer 1

up vote 6 down vote accepted

You can use the decorate operation (don't use rounded corners with decoration or read carefully the answer to How to draw a decorated rectangle with rounded corners?):

enter image description here

\documentclass[tikz, border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\draw[thick, fill=brown!70]
%
decorate[decoration={zigzag,segment length=1.0mm, amplitude=.2mm}]
{(0,0) -- ++(0,.5) -- ++(4,0) -- ++(0,-.5) }
%
[rounded corners=1ex]-- ++(0, -.5) -- ++(-4,0) -- cycle;
\end{tikzpicture}
\end{document}
share|improve this answer
1  
Learn something new every day. I didn't know that decorations could be applied to partial paths like this! Regarding rounded corners and decorations, we had a question on that a while back: tex.stackexchange.com/q/38989/86 –  Loop Space Nov 1 '12 at 15:33
    
@AndrewStacey Thanks for the link about rounded corners and decorations. –  Paul Gaborit Nov 1 '12 at 15:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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