7

This question already has an answer here:

I saw this diagram on an exam paper and noticed that it was too clean to have been made in the usual MS Word program. So I figured that it may have been made in either TikZ or PSTricks.

What stood out for me was the method of shading the region, which was to use a 'dotted background' as opposed to the usual grey paint. Is this something possible in either TikZ or PSTricks? I have never seen it before in either of the two, but perhaps you may have. I can't imagine somebody manually assigning dots coordinate by coordinate.

enter image description here

marked as duplicate by Thruston, Romain Picot, Stefan Pinnow, user31729, Zarko May 10 '16 at 8:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

Here's a pattern I defined by taking the coordinates from your image. One could probably use some external program such as octave or the scripting capabilities of luatex to generate new points.

Just taking purely random points doesn't really work, because those won't be distributed evenly enough.

\documentclass[tikz,margin=1cm]{standalone}
\usetikzlibrary{patterns}

\pgfmathsetmacro\sprayRadius{.2pt}
\pgfmathsetmacro\sprayPeriod{.5cm}

\pgfdeclarepatternformonly{spray}{\pgfpoint{-\sprayRadius}{-\sprayRadius}}{\pgfpoint{1cm + \sprayRadius}{1cm + \sprayRadius}}{\pgfpoint{\sprayPeriod}{\sprayPeriod}}{
    \foreach \x/\y in {2/53,6/52,11/48,23/49,20/47,32/46,41/47,47/51,56/52,46/44,4/43,16/42,33/41,41/37,49/35,55/31,37/35,44/30,28/37,24/36,17/37,7/38,0/31,8/29,18/31,28/30,37/28,30/27,46/24,51/21,24/23,12/24,4/21,18/19,12/16,31/21,38/18,26/16,46/16,56/12,52/10,45/8,51/4,37/12,35/7,24/9,14/9,2/12,8/6,15/4,27/0,34/1,40/1} {
        \pgfpathcircle{\pgfpoint{(\x + random()) / 57 * \sprayPeriod}{\sprayPeriod - (\y + random()) / 55 * \sprayPeriod}}{\sprayRadius}
    }
    %\foreach \i in {1,...,100} {
    %   \pgfpathcircle{\pgfpoint{1cm * random()}{1cm * random()}}{\sprayRadius}
    %}
    \pgfusepath{fill}
}

\begin{document}
    \begin{tikzpicture}
        \filldraw[pattern=spray] (0,0) -- (3,3) -- (2,3) -- cycle;
    \end{tikzpicture}
\end{document}

result

1
\documentclass[border=4,pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}

\psset{unit=2,arrowscale=2}
\begin{pspicture}(-1,-1)(5,3)
\psaxes[labels=none,ticks=none]{->}(0,0)(-0.5,-0.5)(4.5,2.5)[$x$,-90][$y$,180]
\psset{origin={1,0}}
\psRandom[dotsize=1pt,randomPoints=2000](3,3){%
    \psline[linestyle=none](0,0)(2.5;60)(3;45)(0,0)}
\psline(2.5;60)\psline(3;45)
\pscircle[fillstyle=solid,fillcolor=white](0,0){2mm}
\Large\uput{4mm}[-90](1,0){1}
\psarc[arrows=->](0,0){0.5}{0}{45}\rput(1,0){\rput(0.75;22.5){$\frac{\pi}{4}$}}
\psarc[arrows=->](0,0){1}{0}{60}\rput(1,0){\rput(1.25;30){$\frac{\pi}{3}$}}
\end{pspicture}

\end{document}

enter image description here

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