Tikz:淡化蛇形曲线

Tikz:淡化蛇形曲线

尝试通过敲击来调整这个答案:https://tex.stackexchange.com/a/134297/3929具有蛇形装饰的路径。

有点效果,但我希望曲线的粗细均匀。下图中的曲线看起来或多或少像是用书法笔画的。

有任何想法吗?

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{fadings}%
\usetikzlibrary{decorations.pathmorphing}

\begin{tikzfadingfrompicture}[name=custom fade]%
\path(-0.2cm,0.2cm) rectangle (1.2cm,2.5cm); % Arrow line is an overlay!
\pgfinterruptboundingbox
\draw[
very thick,
transparent!20,
decorate,decoration=snake,
line around/.style={
  decoration={
    pre=curveto,
    pre length=0*#1,
    post length=#1,
  },
},
line around=3pt,
->] (0cm,0cm) -- ++ (0,2cm);
\endpgfinterruptboundingbox
\end{tikzfadingfrompicture}


\begin{document}

\begin{tikzpicture}
\draw[
draw=none,
path fading=custom fade,
top color=red,
bottom color=blue,
] (0,0) rectangle (1cm,-2cm);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案1

代码在问题中链接的 percusse 的答案对我来说实际上不起作用。我猜这是由于 TikZ 的变化。从 TikZ 的角度来看,2013 年基本上是古代历史。

我认为这里的问题在于你不希望 TikZ 像默认那样适应淡入淡出。那么你只需要确保一切都适合以获得预期的结果。

褪色的阴影蛇

注意

    line around/.style={
      decoration={
        pre=curveto,
        pre length=0*#1,
        post length=#1,
      },
    },
    line around=3pt,

相当于

  decoration={
    pre=curveto,
    pre length=0pt,
    post length=#3pt,
  },

并且我不完全确定此代码背后的想法是什么,因此为了简单起见,我在示例中将其删除。

\documentclass[tikz,border=10pt,multi]{standalone}
% question by daleif at https://tex.stackexchange.com/q/315284/
% OP's code is based on percusse's answer at https://tex.stackexchange.com/a/134297/3929
\usetikzlibrary{fadings,decorations.pathmorphing}

\begin{tikzfadingfrompicture}[name=custom fade]%
  \path [fill=transparent!100] (-5mm,-10mm) rectangle (5mm,10mm);
  \draw[
    very thick,
    transparent!20,
    decorate,
    decoration=snake,
    decoration={
      pre=curveto,
      pre length=0pt,
      post length=3pt,
    },
    ->
  ] (0,-1cm) -- ++ (0,2cm);
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
  \path[
    path fading=custom fade,
    fit fading=false,
    top color=red,
    bottom color=blue,
  ] (-5mm,-10mm) rectangle (5mm,10mm);
\end{tikzpicture}
\end{document}

但迄今为止,这并不令人满意。

相关内容