我的问题很简单:如何在网格上画一条“蛇”线?
更具体地说,请参阅上传图片,但有重要的区别:我希望弯曲的连接线是界,我认为正确的做法是,出切线为 45 度,入切线为 -135 度。
我的代码是这样的:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[darkstyle/.style={circle,draw,fill=gray!20}]
\foreach \x in {0,...,6}
\foreach \y in {0,...,3}
{
\node [darkstyle] (\x, \y) at (\x, \y)
{ };
}
\draw (0, 0)--(3, 3) to[out=45, in=-135] (4, 3);
\end{tikzpicture}
\end{document}
但是我有一个错误:
./main.tex:57: Dimension too large.
<recently read> \pgf@ya
l.57 ...w (0, 0)--(3, 3) to[out=45, in=-135] (4, 3)
;
我不明白为什么我会犯这个错误。
我错过了什么?
谢谢!
答案1
根据箭头提示的要求进行编辑
输出
首先是最可爱的版本,其造型如下:
\draw [serpent,-{Arc Barb[reversed,length=15pt,width=25pt]}] (1, 1)
得到:
或以下版本:
代码
\documentclass[12pt,tikz]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\tikzset
{
darkstyle/.style=
{
circle,draw,fill=gray!20
},
serpent/.style =
{
line join = round,
line width=9pt,
line cap=round,
red,
%opacity=.7, % see below
},
}
\begin{tikzpicture}
\foreach \x in {1,...,7}
{
\foreach \y in {1,...,4}
{
\node[darkstyle] at (\x, \y) {};
}
}
\begin{scope}[transparency group, opacity=0.70] %for correct transparency of arrow tips
\draw [serpent,-{Triangle Cap []. Fast Triangle[] Fast Triangle[]}] (1, 1)
foreach \k in {1,2}
{
-- (3+2*\k,5) arc [radius = .25 * sqrt(2), start angle = 135, delta angle = -180]
-- (2*\k-1,0) arc [radius = .25 * sqrt(2), start angle = 135, delta angle = 180]
}
-- (6.8,2.8) ;
;
\end{scope}
\end{tikzpicture}
\end{document}
干杯,