[Tex/LaTex] Morphing only a part of a full path in tikz

tikz-pgf

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}

Best Answer

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}