使用 tikz 绘制水滴

使用 tikz 绘制水滴

我画了几个箭头如下:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing, arrows.meta, arrows}
\begin{document}

\begin{tikzpicture}[>=Stealth]
\draw [line width = 1pt, decorate, decoration = {snake, amplitude = 1mm, segment length = 1cm, post length = 1mm},arrows={->[length=0.5cm,width=0.5cm]}] (-3,-1) -- (-3,1);
\draw [line width = 1pt, decorate, decoration = {snake, amplitude = 1mm, segment length = 1cm, post length = 1mm},arrows={->[length=0.5cm,width=0.5cm]}] (-2,-1) -- (-2,1);
\end{tikzpicture}

\end{document}

我现在想知道是否有可能绘制从每个箭头两侧落下的水滴。我知道我可以获取水滴的 svg,然后将其添加进去,但我想知道这是否已经使用 tikz 完成?

答案1

有更有效的方法来实现阴影效果(见下文),而且有点“卡通”,但无论如何:

\documentclass[tikz,border=5]{standalone}
\tikzset{%
  raindrop/.pic={
    code={\tikzset{scale=1/10}
 \clip [preaction={top color=blue!50!cyan!50, bottom color=blue!50!cyan}]
 (0,0)  .. controls ++(0,-1) and ++(0,1) .. (1,-2)
 arc (360:180:1)
 .. controls ++(0,1) and ++(0,-1) .. (0,0) -- cycle;
% %
 \foreach \j in {1,3,...,20}
 \shade [top color=blue!50!cyan!50, shift=(270:0), xscale=1-\j/40,yscale=1-\j/80, white, opacity=1/15]
 [rotate=-\j] (0,0)  .. controls ++(0,-1) and ++(0,1) .. (1,-2)
 arc (360:180:1)
 .. controls ++(0,1) and ++(0,-1) .. (0,0) -- cycle;
  }}}

\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,10}
  \path (rand,-\i/8+rand/4) pic {raindrop};
\end{tikzpicture}
\end{document}

在此处输入图片描述

这里使用了自定义径向阴影。颜色的选择很重要(特别是在阴影焦点处混合了多少白色),否则它最终看起来像圣诞装饰:

\documentclass[tikz,border=5]{standalone}

\pgfdeclareradialshading[droplet color]{droplet}{\pgfqpoint{-10bp}{-10bp}}{%
 color(0bp)=(droplet color!50!white);
 color(9bp)=(droplet color!75!white);
 color(18bp)=(droplet color!85!black);
 color(25bp)=(droplet color);
 color(50bp)=(droplet color!50!white)}

\colorlet{droplet color}{blue!50!cyan}
\tikzset{%
  raindrop/.pic={
    code={\tikzset{scale=1/10}
 \shade [shading=droplet]
 (0,0)  .. controls ++(0,-1) and ++(0,1) .. (1,-2)
 arc (360:180:1)
 .. controls ++(0,1) and ++(0,-1) .. (0,0) -- cycle;
  }}}

\begin{document}
\begin{tikzpicture}
\foreach \i in {1,...,10}
  \path (rand,-\i/8+rand/4) pic {raindrop};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容