[Tex/LaTex] Fill style that looks like hand-drawn / hand-filled with crayon

tikz-pgf

How to generate in LaTeX (TikZ or something similar) the following image:

crayon fill for cylinder crayon fill for triangle

This was not drawn by hand, as far as I known, but with some Mac tool.

Best Answer

Here is a quick one: I've used the decoration that Forkrul Assail linked to and basically it's going back and forth between the corners just as you would do to hatch. However it's not really following the outer contour and you can make it more detailed if you define this as a genuine decoration following precisely the shape border. I didn't do it because I think Inkscape or something similar is much easier to perform this and I doubt that it is worth automating. Nevertheless the idea is essentially the same for the decoration anyhow.

Also much to my surprise the line join option is really showing a difference.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,calc,positioning,decorations}

\makeatletter
\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=1mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
        }
    }
    \state{final}{}
}
\makeatother

\begin{document}
\begin{tikzpicture}[decoration={penciline,amplitude=2pt}]
\node[regular polygon,regular polygon sides=3,minimum height=2cm,draw] (a) {};
\node[below= 0.5cm of a] {\textsc{Working Copy}};
\draw[blue,opacity=0.3,decorate,line width=1mm,line join=round] (a.corner 3)
\foreach \x[remember=\x as \lastx(initially 0)] in {0.07,0.15,...,1.1}{
 -- ($(a.corner 1)!\lastx!(a.corner 2)$) --($(a.corner 3)!\lastx+0.05!(a.corner 2)$)
}--(a.corner 2);

\node[cylinder, shape border rotate=90, aspect = 0.65,draw,
        minimum height=1.7cm,minimum width=1.5cm] (b) at (4cm,0.2cm) {};
\node[below= 0.45cm of b] {\textsc{Copying Work}};
\draw[red,opacity=0.3,decorate,line width=0.9mm,line join=bevel] (b.after top)
\foreach \x[remember=\x as \lastx(initially 0)] in {0.1,0.2,...,1.1}{
 -- ($(b.after top)!\lastx!(b.before bottom)$) --($(b.after top)!\lastx+0.05!(b.before top)$)
} --(b.before bottom) 
\foreach \x[remember=\x as \lastx(initially 0)] in {0.1,0.2,...,1.1}{
 -- ($(b.before bottom)!\lastx!(b.after bottom)$) -- ($(b.before top)!\lastx+0.05!(b.after bottom)$)
};
\end{tikzpicture}
\end{document}

enter image description here