我正在尝试复制这张图片(来自维基百科)与TikZ:
左边的部分很简单,但我很难对右边的部分提出想法。
答案1
这采用非线性变换来产生类似的输出。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\definecolor{myblue}{RGB}{191,202,236}
\definecolor{myred}{RGB}{185,134,146}
\usepgfmodule{nonlineartransformations}
\makeatletter
\def\curvytransformation{%
\pgfmathsetmacro{\myx}{\pgf@x+0.3*\pgf@y-3*sin(\pgf@y*2)}%
\pgfmathsetmacro{\myy}{\pgf@y-10*sin(\pgf@x)}%
\pgf@x=\myx pt%
\pgf@y=\myy pt%
}
\makeatother
\begin{document}
\begin{tikzpicture}[>=stealth]
\begin{scope}[xshift=-10cm,local bounding box=L]
\draw[fill=myblue] (0,0) rectangle (8,8);
\draw[help lines] (0,0) grid (8,8);
\draw[thick,fill=myred] (1,1) rectangle (7,7);
\draw[help lines] (1,1) grid (7,7);
\draw[very thick,<->] (1,7) |- (7,1);
\end{scope}
%
\begin{scope}[local bounding box=R]
\pgftransformnonlinear{\curvytransformation}%
\draw[fill=myblue] (0,0) rectangle (8,8);
\draw[help lines] (0,0) grid (8,8);
\draw[thick,fill=myred] (1,1) rectangle (7,7);
\draw[help lines] (1,1) grid (7,7);
\path (1,1) coordinate (o) (1,1.1) coordinate (y) (1.1,1) coordinate (x);
\end{scope}
\draw[fill=white,fill opacity=0.2] let \p1=($(y)-(o)$),\p2=($(x)-(o)$),
\n1={atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in
[fill=white,fill opacity=0.2] (o) -- ++(\n1:6.25) coordinate (y')
-- ++(\n2:6.25) -- ++(\n1+180:6.25) coordinate (x')
-- cycle;
\draw[very thick,<->] (y') -- (o) -- (x');
%
\draw[-stealth,thick] (-1.5,4) to[bend left=10] node[above]{$f$} (0.5,4);
\end{tikzpicture}
\end{document}