TikZ 中的水彩阴影

TikZ 中的水彩阴影

如何创建类似水彩画的“阴影”来突出显示图形上的某些节点,如下图所示?

请注意,我不需要用颜色来填充形状,也不需要它有可变的强度,也不需要像tikz 中的水彩画问题。

带有水彩般节点突出显示的图形

答案1

我不确定你想要显示的内容。右边的还是左边的?它总是圆形的吗?

我假设并非总是圆形,而是两者都有。不过,我使用圆形作为示例,但这只是为了方便。

有四种可能:

4 种可能性

四个圆圈均以相同的方式绘制,gray不透明度为 50%,宽度为 10 毫米。第一个圆圈使用样式添加了蓝色阴影。其他三个圆圈则pic使用了各种绘画、阴影等组合。

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{shadows,fit,decorations.pathmorphing}
\tikzset{
  overfill/.pic={
    \node [pic actions] {};
    \scoped[scale=1.25]{\node [fill=#1!50, scale=1.25, opacity=.5] {};}
  },
  shadow fill/.style={general shadow={shadow scale=1.25, inner color=#1!25, outer color=#1!5}},
  over paint/.pic={
    \node (a) [pic actions] {};
    \scoped[scale=1.25]{\node (b) [shape=rectangle, fit=(a)] {};}
    \path [decoration={random steps, segment length=2.5mm}, rounded corners=1.25pt, decorate, fill=#1!50, opacity=.5] (b.north) -| (b.south east) -| (b.north west) -- cycle;
  },
  shadow over paint/.pic={
    \node (a) [pic actions] {};
    \scoped[scale=1.25]{\node (b) [shape=rectangle, fit=(a)] {};}
    \path [decoration={random steps, segment length=2.5mm}, rounded corners=2pt, decorate, general shadow={shadow scale=1.25, inner color=#1!50, outer color=#1!25, opacity=.5}] (b.north) -| (b.south east) -| (b.north west) -- cycle;
  },
}
\begin{document}
\begin{tikzpicture}
  \node [circle, draw=gray, draw opacity=.5, minimum size=10mm, shadow fill=blue] {};
  \pic [circle, draw=gray, draw opacity=.5, minimum size=10mm] at (2,0) {overfill=green};
  \pic [circle, draw=gray, draw opacity=.5, minimum size=10mm] at (0,-2) {over paint=orange};
  \pic [circle, draw=gray, draw opacity=.5, minimum size=10mm] at (2,-2) {shadow over paint=red};
\end{tikzpicture}
\end{document}

答案2

我不确定您是否想要整个图表,但这里有一个示例节点。构建它的命令可能会根据您想要的用途而改变。

输出

示例图片

代码

\documentclass[margin=10pt]{standalone}
\usepackage{tikz}

\usetikzlibrary{fadings,decorations.pathmorphing}

\tikzfading[name=fade out,
    inner color=transparent!0,
    outer color=transparent!100]

\tikzset{
    nod/.style={circle, draw=blue!50!green, fill=white, inner sep=0, outer sep=0}
}

\newcommand{\mynode}[4][1]{
\scalebox{#1}{
    \node[nod, minimum size=3cm] (#2) at (#3) {};
    \fill[#4,
        decoration={random steps,segment length=4mm,amplitude=3mm},
        decorate,
        rounded corners,
        path fading=fade out
    ] (#3) circle (2cm);
}
}

\begin{document}
\begin{tikzpicture}

\mynode{A}{0,0}{yellow!30}

\end{tikzpicture}
\end{document}

相关内容