细分随机区域

细分随机区域

在此处输入图片描述

\begin{tikzpicture}[scale=1.1]      
    \path
    coordinate (aux0) at (1,1.5)
    coordinate (aux1) at (1.7,3.5)
    coordinate (aux2) at (8,3.5)
    coordinate (aux3) at (7,6)
    coordinate (aux4) at (4,1.1)
    coordinate (aux5) at (7,1.3)
    coordinate (aux6) at (2,5.7)
    coordinate (aux7) at (5,5.1)
    coordinate (esp1) at (0.2,2.5)
    coordinate (esp2) at (1.5,1.5)
    coordinate (esp3) at (3,0.9)
    coordinate (esp4) at (5.5,1.4)
    coordinate (esp5) at (6,0.5)
    coordinate (esp6) at (6.75,2)
    coordinate (esp7) at (7.7,3)
    coordinate (esp8) at (5.5,4.5)
    coordinate (esp9) at (3.8,4.8)
    coordinate (esp10) at (1.5,4)
    ;
    \draw[line width=0.8pt]
    (esp1) to[out=-90,in=170]
    (esp2) to[out=-10,in=170]
    (esp3) to[out=-10,in=180]
    (esp4) to[out=0,in=180]
    (esp5) to[out=10,in=-150]
    (esp6) to[out=20,in=-90]
    (esp7) to[out=90,in=-60]
    (esp8) to[out=120,in=0]
    (esp9) to[out=180,in=0]
    (esp10) to[out=180,in=90]
    cycle;    
    \clip
    (esp1) to[out=-90,in=170]
    (esp2) to[out=-10,in=170]
    (esp3) to[out=-10,in=180]
    (esp4) to[out=0,in=180]
    (esp5) to[out=10,in=-150]
    (esp6) to[out=20,in=-90]
    (esp7) to[out=90,in=-60]
    (esp8) to[out=120,in=0]
    (esp9) to[out=180,in=0]
    (esp10) to[out=180,in=90]
    cycle;    

    \end{tikzpicture}

*在此输入图片描述*

强文本

我有一个随机区域(我已经知道如何在 TIKZ 中构建),我需要将同一区域划分为矩形(它们不必都是相同大小),并且只有其中一个矩形需要应用阴影。有什么想法从哪里开始吗?**

答案1

您已经提供了一个非常好的起点。这是众多可能的方法之一。您可以使用它decorations.markings来定义沿轮廓的坐标。它们可用于绘制(剪切的)矩形。取消注释

[label=\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}]

看看哪个标记位于哪里。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.markings,patterns} 
\begin{document}
\begin{tikzpicture}[scale=1.1]      
    \path
    coordinate (aux0) at (1,1.5)
    coordinate (aux1) at (1.7,3.5)
    coordinate (aux2) at (8,3.5)
    coordinate (aux3) at (7,6)
    coordinate (aux4) at (4,1.1)
    coordinate (aux5) at (7,1.3)
    coordinate (aux6) at (2,5.7)
    coordinate (aux7) at (5,5.1)
    coordinate (esp1) at (0.2,2.5)
    coordinate (esp2) at (1.5,1.5)
    coordinate (esp3) at (3,0.9)
    coordinate (esp4) at (5.5,1.4)
    coordinate (esp5) at (6,0.5)
    coordinate (esp6) at (6.75,2)
    coordinate (esp7) at (7.7,3)
    coordinate (esp8) at (5.5,4.5)
    coordinate (esp9) at (3.8,4.8)
    coordinate (esp10) at (1.5,4)
    ;
    \draw[line width=0.8pt,postaction={decorate,
        decoration={markings,
        mark=between positions 0 and 1 step 0.1 with
        {\coordinate%[label=\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}]
         (p\pgfkeysvalueof{/pgf/decoration/mark info/sequence number});}}}]
    (esp1) to[out=-90,in=170]
    (esp2) to[out=-10,in=170]
    (esp3) to[out=-10,in=180]
    (esp4) to[out=0,in=180]
    (esp5) to[out=10,in=-150]
    (esp6) to[out=20,in=-90]
    (esp7) to[out=90,in=-60]
    (esp8) to[out=120,in=0]
    (esp9) to[out=180,in=0]
    (esp10) to[out=180,in=90]
    cycle;    
    \clip
    (esp1) to[out=-90,in=170]
    (esp2) to[out=-10,in=170]
    (esp3) to[out=-10,in=180]
    (esp4) to[out=0,in=180]
    (esp5) to[out=10,in=-150]
    (esp6) to[out=20,in=-90]
    (esp7) to[out=90,in=-60]
    (esp8) to[out=120,in=0]
    (esp9) to[out=180,in=0]
    (esp10) to[out=180,in=90]
    cycle;    
    \draw[red,thick,pattern=north east lines,pattern color=red] (p5|-p1) rectangle (p8|-p7);
    \draw[red,thick] (p1) -| (p3) (p10) |- (p1) (p9) |- (p1) (p8) |- (p1)
    (p8) |- (p7) (p4) |- (p1) (p2) |- (p6) (p9) |- (p8|-p7);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容