填充随机构造的封闭路径的内部

填充随机构造的封闭路径的内部

我不确定如何填充随机生成的(通过随机装饰)路径的内部。

我从这个问题的答案中给出的代码开始问题并致力于此,因为基本目的与之相关。

图像

填充和绘制的线条并不完全相同,因为各自应用了随机装饰。

问题)

如何将填充应用于绘制线所限定的内部区域?

(另外,顺便问一下,在这种情况下,我该如何使装饰箭头变大?我可以将装饰箭头应用于绘制的路径而不破坏其他装饰吗?)

\documentclass[border=0pt]{standalone}\usepackage{mathtools,tikz,tkz-euclide}\usetikzlibrary{decorations.markings,arrows,decorations.pathmorphing}\usetkzobj{all}\begin{document}\begin{tikzpicture}[label]\tkzInit[xmin=-0.8,xmax=10,ymin=-0.4,ymax=8.4] \tkzClip
\tikzset{every node}=[font=\normalsize]

%here_we_make_such_a_dashing
\tikzstyle{finelydashed}=[dash pattern=on 4pt off 7pt]
\tikzstyle{coarselydashed}=[dash pattern=on 7pt off 8pt]

%here_we_make_such_a_shading
\pgfdeclarepatternformonly{ltrdiagonals}%
{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{10pt}{10pt}}%
{\pgfqpoint{9pt}{9pt}}{\pgfsetlinewidth{0.4pt}\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}%
\pgfpathlineto{\pgfqpoint{9.1pt}{9.1pt}}%
\pgfusepath{stroke}}%

%here_we_make_such_a_grid
\draw[help lines,color=black!90](0,0)grid(8,8);

%here_we_define_our_several_points
\tkzDefPoint(1,2){v}\tkzDefPoint(7,2){w}  
\tkzDefPointBy[rotation=center w angle -42](v)
\tkzGetPoint{C}
\tkzDefPointBy[rotation=center v angle 63](w)
\tkzGetPoint{D}
\tkzInterLL(v,D)(C,w)\tkzGetPoint{x}


\tkzDefMidPoint(v,x)\tkzGetPoint{M}

\draw[shade,top color=black!96,bottom color=black!16,fill opacity=0.64,decoration=   {random steps,segment length=22pt,amplitude=11pt},decorate,line width=2pt,rounded corners=8pt](v)--(1.7,3.2)--(4,4)--(6,3)--(w)--(7.4,1)--(0.4,0.4)--(v);
\fill[even odd rule,pattern=ltrdiagonals,pattern color=black!84,decoration={random steps,segment length=24pt,amplitude=0.24cm},decorate,line width=2pt,rounded corners=8pt](v)--(1.7,3.2)--(4,4)--(6,3)--(w)--(7.4,1)--(0.4,0.4)--(v);

%here_we_label_each_node_so
\tkzLabelPoint[above left](v){\LARGE $\boldsymbol{\mathbf{H}_{\;n\;v}}\,$}
\tkzLabelPoint[above left](x){\LARGE $\mathbf{x_{\;n}}$}  
\tkzLabelPoint[right](w){\LARGE $\;\boldsymbol{\mathbf{H}_{\;n\;w}}$}
\tkzLabelAngle[pos=0.64](v,x,w){\large $\boldsymbol{\varphi}$}
\tkzLabelAngle[pos=0.64](w,v,x){\large $\boldsymbol{\rho}$}
\tkzLabelPoint[left](M){$\boldsymbol{2\cdot\mu}\;$}

%here_we_construct_each_line_so
\begin{scope}[decoration={markings,mark=at position 0.5 with {\LARGE\arrow{triangle 45},color=black!96}}]
\draw[-,decorate](v)--(x);
\draw[-,decorate](v)--(w);
\draw[-,decorate](x)--(w);
\end{scope}
\draw[-,line width=1.2pt,coarselydashed,color=black!96](v)--(x);
\draw[-,line width=1.2pt,coarselydashed,color=black!96](v)--(w);
\draw[-,line width=1.2pt,coarselydashed,color=black!96](x)--(w);
\tkzDrawPoints[color=black,shape=circle,fill=black!64,size=16pt](v,x,w)
\tkzMarkAngle[scale=1,line width=1.2pt,finelydashed,color=black!96](v,x,w)
\tkzMarkAngle[scale=1,line width=1.2pt,finelydashed,color=black!96](w,v,x)
\end{tikzpicture}\end{document}

在此处输入图片描述

答案1

您需要重复使用带有postaction,preaction密钥的相同路径。

\documentclass[border=0pt]{standalone}
\usepackage{mathtools,tikz,tkz-euclide}\usetikzlibrary{decorations.markings,arrows,decorations.pathmorphing}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[label]
\tkzInit[xmin=-0.8,xmax=10,ymin=-0.4,ymax=8.4] 
\tkzClip
\tikzset{every node}=[font=\normalsize]
%here_we_make_such_a_dashing
\tikzstyle{finelydashed}=[dash pattern=on 4pt off 7pt]
\tikzstyle{coarselydashed}=[dash pattern=on 7pt off 8pt]

%here_we_make_such_a_shading
\pgfdeclarepatternformonly{ltrdiagonals}%
{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{10pt}{10pt}}%
{\pgfqpoint{9pt}{9pt}}{\pgfsetlinewidth{0.4pt}\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}%
\pgfpathlineto{\pgfqpoint{9.1pt}{9.1pt}}%
\pgfusepath{stroke}}%

%here_we_make_such_a_grid
\draw[help lines,color=black!90](0,0)grid(8,8);

%here_we_define_our_several_points
\tkzDefPoint(1,2){v}\tkzDefPoint(7,2){w}  
\tkzDefPointBy[rotation=center w angle -42](v)
\tkzGetPoint{C}
\tkzDefPointBy[rotation=center v angle 63](w)
\tkzGetPoint{D}
\tkzInterLL(v,D)(C,w)\tkzGetPoint{x}


\tkzDefMidPoint(v,x)\tkzGetPoint{M}

\draw[%shade,
     top color=black!96,
     bottom color=black!16,
     fill opacity=0.64,
     decoration={random steps,segment length=22pt,amplitude=11pt},
     decorate,
     line width=2pt,
     rounded corners=8pt,
     postaction={fill,pattern=ltrdiagonals,pattern color=black!84}
     ](v)--(1.7,3.2)--(4,4)--(6,3)--(w)--(7.4,1)--(0.4,0.4)--(v);


%here_we_label_each_node_so
\tkzLabelPoint[above left](v){\LARGE $\boldsymbol{\mathbf{H}_{\;n\;v}}\,$}
\tkzLabelPoint[above left](x){\LARGE $\mathbf{x_{\;n}}$}  
\tkzLabelPoint[right](w){\LARGE $\;\boldsymbol{\mathbf{H}_{\;n\;w}}$}
\tkzLabelAngle[pos=0.64](v,x,w){\large $\boldsymbol{\varphi}$}
\tkzLabelAngle[pos=0.64](w,v,x){\large $\boldsymbol{\rho}$}
\tkzLabelPoint[left](M){$\boldsymbol{2\cdot\mu}\;$}

%here_we_construct_each_line_so
\begin{scope}[decoration={markings,mark=at position 0.5 with {\LARGE\arrow{triangle 45},color=black!96}}]
\draw[-,decorate](v)--(x);
\draw[-,decorate](v)--(w);
\draw[-,decorate](x)--(w);
\end{scope}
\draw[-,line width=1.2pt,coarselydashed,color=black!96](v)--(x);
\draw[-,line width=1.2pt,coarselydashed,color=black!96](v)--(w);
\draw[-,line width=1.2pt,coarselydashed,color=black!96](x)--(w);
\tkzDrawPoints[color=black,shape=circle,fill=black!64,size=16pt](v,x,w)
\tkzMarkAngle[scale=1,line width=1.2pt,finelydashed,color=black!96](v,x,w)
\tkzMarkAngle[scale=1,line width=1.2pt,finelydashed,color=black!96](w,v,x)
\end{tikzpicture}
\end{document}

在此处输入图片描述

正如你所见,random steps这个选项玩得不好rounded corners。也可以看看应该使用 \tikzset 还是 \tikzstyle 来定义 TikZ 样式?

相关内容