Filling a form having different line styles with a pattern

I want to make a small technical drawing in tikz. Cuts in technical drawings are shown with a handwritten line which is realized with the “pencildraw” (derived from another question here). The rest should be straight lines. Because it is a cut, the pattern “north east lines” should fill the whole form.

I added a minimal example here:




decoration={random steps,segment length=4pt, amplitude=0.8pt}
line cap= round

\draw[pencildraw,pattern = north east lines] (0,0) --(2,0)(0,2) --(2,2);

\draw[pattern = north east lines] (0,0) to (0,2)(2,0) to (2,2);

\fill[pattern = north east lines] (0,0) rectangle (2,2);



rendered view of above code

With this approach, the north west lines draw over the handwritten line. Also, the boundaries are not one continuous line, which makes the ends look terrible in cases.

Solutions Collecting From Web of "Filling a form having different line styles with a pattern"

You need to create the enclosing path in one go then it can clip the pattern lines properly.

     decoration={random steps,segment length=4pt, amplitude=0.8pt}}]

\draw[pattern = north east lines]  decorate[pencildraw]{(0,0) --(2,0)} --(2,2) 
                                                 decorate[pencildraw]{--(0,2)} --cycle;


enter image description here