绘制虚线背景

绘制虚线背景

是否可以使用 TikZ 或 PSTricks 用随机分配的点填充区域?我无法想象有人手动逐个坐标分配点。

答案1

这是我通过从图片中获取坐标定义的图案。您可能可以使用某些外部程序(例如 octave)或 luatex 的脚本功能来生成新点。

仅仅取纯粹​​随机的点实际上不起作用,因为这些点分布不够均匀。

\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}

结果

答案2

\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}

在此处输入图片描述

相关内容