答案1
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[scale=2]
\pgfmathsetmacro{\rbez}{0.08}
\filldraw[fill=yellow] (45:0.4)
arc[start angle=45,end angle=-45,radius=0.4]
.. controls +(45:\rbez) and +(180:\rbez) .. (0.5,-0.2)
.. controls +(0:\rbez) and +(135:\rbez) .. ($(1,0)+(225:0.4)$)
arc[start angle=225,end angle=135,radius=0.4]
.. controls +(225:\rbez) and +(0:\rbez) .. (0.5,0.2)
.. controls +(180:\rbez) and +(-45:\rbez) .. cycle;
\draw (45:0.4) arc[start angle=45,end angle=315,radius=0.4];
\draw ($(1,0)+(-135:0.4)$) arc[start angle=-135,end angle=135,radius=0.4];
\end{tikzpicture}
\end{document}
答案2
使用in
和out
语法,您可以明确设置角度。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle[radius=0.4] (1,0) circle[radius=0.4];
\draw[fill=blue] (-45:0.4) arc[start angle=-45,end angle=45,radius=0.4]
to[out=-45,in=180] (0.5,0.2)
to[out=0,in=-135] ([xshift=1cm]135:0.4)
arc[start angle=135,end angle=225,radius=0.4] to[out=135,in=0]
(0.5,-0.2) to[out=180,in=45] cycle;
\end{tikzpicture}
\end{document}
这个结果并不唯一。即使你要求对称,也有两个参数可以改变,in looseness
和out looseness
。整体松散度大致对应\rbez
于polyn 的精彩回答,但实际上你可以引入其中两个。
答案3
如果你愿意让中点不精确到(0.5,0.2)
但小于下面的线宽,则可以仅用弧线绘制桥梁,并且没有额外的张力参数。
\documentclass[tikz, border=0.1cm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[fill=red]
(45:0.4)
arc[radius={sqrt(0.5)-0.4}, start angle=-135, end angle=-45]
arc[radius=0.4, start angle=135, end angle=225]
arc[radius={sqrt(0.5)-0.4}, start angle=45, end angle=135]
arc[radius=0.4, start angle=-45, end angle=45];
\draw (0,0) circle[radius=0.4];
\draw (1,0) circle[radius=0.4];
\end{tikzpicture}
\end{document}