tikz 中的水彩画

tikz 中的水彩画

是否可以像这张图片一样用水彩填充形状

在此处输入图片描述

使用 tikz 或 pgfplots?

来源:http://bartoszmilewski.com/2015/07/29/representable-functors/

答案1

有一些“廉价”的方法来生成复杂的图片。但正如 TiZ 手册说,

这些是所有格式中便携性最差的,而且它们对渲染器的要求最高。它们速度很慢,而且可能无法正确打印!

\documentclass[tikz,border=9]{standalone}
\begin{document}
\pgfdeclarefunctionalshading{watercolor}{\pgfpoint{-25bp}{-25bp}}{\pgfpoint{25bp}{25bp}}{}{
    -0.1 0.651
    exch 4 2 roll
    12.5 div exch 12.5 div 1 index dup mul add
    true
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {dup dup mul 2 index dup mul sub 3 index add 3 1 roll 2 mul mul 3 index add exch 2 copy dup mul exch dup mul add 4 le}{false}ifelse
    {0 0 0}{1 1 1}ifelse
}
\tikz{\shade[shading=watercolor](-10,-10)rectangle(10,10);}
\end{document}

笔记

我并不是说这看起来像一幅水彩画。我也没有试图做到这一点。我对艺术一窍不通。所以剩下的就是你的工作了。

笔记2

水彩画的原理是颜料分子在画布上运行,随着时间的推移速度减慢。因此,模拟水彩画的最佳方法可能是用数字方法求解 PDE。这在 中是不允许的\pgfdeclarefunctionalshading。但是一旦你有了一个 2D 数组,就值得一试。

相关内容