我需要 Tikz 技巧的支持,以便能够自定义沿路径的绘图。
下面是我使用的代码:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{standalone}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{hobby,bending}
\usetikzlibrary{decorations.text}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}
\draw[ %
black, %
line cap = round,
line width = 7pt
] %
(+00.00,-04.35) to [curve through={ %
(+01.25,-02.90) .. % B
(+00.00,-01.45) .. % C
(-01.25,+00.00) .. % D
(+00.00,+01.45) .. % E
(+01.25,+02.90) .. % F
(+00.00,+04.35) .. % G
(-01.25,+02.90) .. % H
(+00.00,+01.45) .. % I
(+01.25,+00.00) .. % J
(+00.00,-01.45) .. % K
(-01.25,-02.90) % L
}
]
(+00.00,-04.35);
\end{scope}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}
\path[ %
postaction={ %
decorate,
decoration={ %
text along path,
reverse path=true,
raise=-0.1cm,
text color = white,
text={
!! MISSING TEXT !!
}
} %
}
] %
(+00.00,-04.35) to [curve through={ %
(+01.25,-02.90) .. % B
(+00.00,-01.45) .. % C
(-01.25,+00.00) .. % D
(+00.00,+01.45) .. % E
(+01.25,+02.90) .. % F
(+00.00,+04.35) .. % G
(-01.25,+02.90) .. % H
(+00.00,+01.45) .. % I
(+01.25,+00.00) .. % J
(+00.00,-01.45) .. % K
(-01.25,-02.90) % L
}
]
(+00.00,-04.35);
\end{scope}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
如果没有第二个范围,输出如下所示:
但我想获得类似的东西:
这个想法是:
- 为了使 Tikz 代码尽可能简单,最好使用坐标来保持“爱好”库功能:最终绘制的是不同的,我不想自己计算所有坐标
- 可以使用类似 text = {--- . . -- . .} 的内容来定义线“类型”,根据需要给出短线、点和长线以及路径上的起点
- 当不同的线交叉时可以定义白色阴影
- 保留定义线宽的可能性(这里是 7pt)
- 保留圆帽。
我尝试使用文本装饰,但没有成功...有什么办法可以解决这个问题吗?使用其他包?定义新命令?
谢谢你的支持 !
答案1
谢谢黑色温和之后,我重新开始阅读 tik-pgf 库的文档,在那里我确实通过使用“dash-pattern”选项找到了答案。
结果代码如下:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass{standalone}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{hobby,bending}
\usetikzlibrary{decorations.text}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\xscale{2.00}
\def\yscale{5.00}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{scope}[dash pattern=on 13pt off 13pt on 45pt off 13pt on 20pt off 13pt]
\draw[ %
blue!40, %
line cap = round,
line width = 7pt
] %
(+00.00,-04.35) to [curve through={ %
(+01.25,-02.90) .. % B
(+00.00,-01.45) .. % C
(-01.25,+00.00) .. % D
(+00.00,+01.45) .. % E
(+01.25,+02.90) .. % F
(+00.00,+04.35) .. % G
(-01.25,+02.90) .. % H
(+00.00,+01.45) .. % I
(+01.25,+00.00) .. % J
(+00.00,-01.45) .. % K
(-01.25,-02.90) % L
}
]
(+00.00,-04.35);
\end{scope}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
无论如何我都会遵循给出的建议并开始使用 Asymptote,因为它似乎提供了许多优点。
谢谢,
用户240879