我怎样才能用像 tikz 中的绘图那样的波浪填充页面的角落?

我怎样才能用像 tikz 中的绘图那样的波浪填充页面的角落?

我使用 tikzpgf 手册封面上的原始绘图制作了以下绘图(关联)。但是现在我想在页面的角落中扩大其中一个波浪形状,并使其颜色逐渐褪去。

我的意思是,我想要一个波浪类型的绘图,填充四分之一圆,当距离圆心的距离增加时,颜色会变淡。另外,当它靠近圆的边缘时,我想减小线段的大小。

在此处输入图片描述

\documentclass[a4paper,12pt,twosided,openright]{book}
\usepackage{tikz,pgfplots,pgfplotstable}
\usetikzlibrary{trees,snakes}


\begin{document}
\tikzstyle{level 1}=[sibling angle=120]
\tikzstyle{level 2}=[sibling angle=60]
\tikzstyle{level 3}=[sibling angle=30]
\tikzstyle{every node}=[fill]
\tikzstyle{edge from parent}=[snake=expanding waves,segment length=1mm,segment angle=10,draw]
\begin{tikzpicture}[shape=circle,very thick,level distance=13mm,cap=round]
\node {} child [color=\A] foreach \A in {red,green,blue}
    { node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
        { node {} child [color=\A!50!\B!50!\C] foreach \C in {black,gray,white}
            { node {} }
        }
    };
\end{tikzpicture}

\end{document}

答案1

这是一个可能的解决方案:

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.north west) circle (3mm);
    \def\max{20}
    \foreach \i in {4,...,\max} {
      \draw[red,line width=.5mm,draw opacity={(\max-\i)/(\max-4)}]
      (current page.north west) ++(\i mm,0)
      arc[start angle=0,end angle=-90,radius=\i mm];
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\end{document}

在此处输入图片描述

厚度可变的另一种版本:

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.north west) circle (3mm);
    \def\max{200}
    \foreach \i in {4,...,\max} {
      \pgfmathsetmacro\prop{(\max-\i)/(\max-4)}
      \draw[red,line width={.7mm*\prop},draw opacity=\prop]
      (current page.north west) ++(\i mm,0)
      arc[start angle=0,end angle=-90,radius=\i mm];
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\end{document}

在此处输入图片描述

答案2

应该感谢 Paul Gabroit,因为我一开始没有理解这个问题。也感谢他提供的代码。以下是他答案的变体。

\documentclass[a4paper]{article}
\usepackage{tikz}
\newcommand\wave[1][north west]{%
  \begin{tikzpicture}[overlay,remember picture]
    \fill[red,line width=.5mm,draw=red] (current page.#1) circle (3mm);
    \def\max{20}
    \foreach \i in {4,...,\max} {
      \draw[red!\i!green,line width=12/\i mm,draw opacity={(\max-\i)/(\max-4)}]
      (current page.#1) circle (\i mm);
    }
  \end{tikzpicture}%
}
\begin{document}
\wave
\wave[north east]
\wave[south west]
\wave[south east]
\end{document}

在此处输入图片描述

答案3

我采取了不同的方法,并为扩展的波浪装饰添加了淡入淡出效果:

衰落的浪潮

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}

\pgfdeclaredecoration{fading waves}{initial}
{
  \state{initial}[width=+\pgfdecorationsegmentlength,next state=wave]
  {\gdef\opacity{1}}

  \state{wave}[switch if less than=+\pgfdecorationsegmentlength to last,
               width=+\pgfdecorationsegmentlength]
  {
    \pgfpathmoveto{
      \pgfpointadd
      {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
      {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
    \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
    \pgfsetstrokeopacity{\opacity}%
    \pgfusepath{stroke}%
    \pgfmathmultiply{0.7}{\opacity}% adjustable fade rate
    \global\edef\opacity{\pgfmathresult}%
  }
  \state{last}[width=+0pt,next state=final]
  {
    \pgfpathmoveto{
      \pgfpointadd
      {\pgfqpoint{-\pgfdecoratedcompleteddistance}{0pt}}%
      {\pgfpointpolar{\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}}}%
    \pgfpatharc{\pgfdecorationsegmentangle}{-\pgfdecorationsegmentangle}{+\pgfdecoratedcompleteddistance}%
    \pgfsetstrokeopacity{\opacity}%
    \pgfusepath{stroke}%
  }
  \state{final}
  {
    \pgfpathmoveto{\pgfpointdecoratedpathlast}
  }
}

\begin{document}

\begin{tikzpicture}[shape=circle,very thick,level distance=13mm,cap=round]
\draw[decorate,decoration={fading waves,angle=45}] (0,0) -- (1,-1);
\end{tikzpicture}

\end{document}

相关内容