![如何使用 TikZ 沿路径变形形状?](https://linux22.com/image/410838/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20TikZ%20%E6%B2%BF%E8%B7%AF%E5%BE%84%E5%8F%98%E5%BD%A2%E5%BD%A2%E7%8A%B6%EF%BC%9F.png)
答案1
这是实现此类目标的一种方法。
\documentclass[tikz,border=3mm]{standalone}
\usepgfmodule{nonlineartransformations}
\usetikzlibrary{fpu}
\newcommand{\PgfmathsetmacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}
\tikzset{declare function={xtransformed(\x,\y)=\pgfkeysvalueof{/tikz/trafos/a}*
sign(\x)*\y*\y;},
trafos/.cd,a/.initial=pi}
\makeatletter
\def\mytransformation{%
\PgfmathsetmacroFPU{\myy}{\pgf@y}%
\PgfmathsetmacroFPU{\myx}{\pgf@x+xtransformed(\pgf@x/1cm,\pgf@y/1cm)}%\typeout{(\the\pgf@x,\the\pgf@y)|->(\myx pt,\myy pt)}
\pgf@x=\myx pt%
\pgf@y=\myy pt%
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw (-2,-2) rectangle (2,2);
\draw (0,0) circle [radius=pi/2];
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}
\pgftransformnonlinear{\mytransformation}
\draw (-2,-2) rectangle (2,2);
\draw (0,0) circle [radius=pi/2];
\end{scope}
\end{tikzpicture}
\end{document}
还有curvilinear
图书馆,但我认为如果你想使用它,你需要将图片分成两半。