Tikz:在圆圈内绘制锯齿线

Tikz:在圆圈内绘制锯齿线

我需要在不使用装饰的情况下在圆圈内绘制一条锯齿线。线条的大小和位置应与圆圈的大小相关。我使用了以下代码:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\node[draw,circle,minimum size=1cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-(0,30pt)$)  --($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)              --($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)   --($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)   --($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)              --($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-(0,30pt)$);
\end{tikzpicture}



\end{document}

得到这个:

enter image description here

问题是,如果我想调整圆圈的大小,垂直线会变得太短(或太长),我必须手动修复“垂直坐标”。

enter image description here

可以锚定相对于节点形状的垂直坐标吗?

答案1

除了将“腿”定义为(0,-30pt)(当然,它不能缩放)之外,您还可以使用($(C.north)-(C.south)$)

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}

\node[draw,circle,minimum size=1.2cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-($(C.north)-(C.south)$)$)--($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)--($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)--($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)--($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)--($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-($(C.north)-(C.south)$)$);
\end{tikzpicture}
\begin{tikzpicture}

\node[draw,circle,minimum size=1.8cm] (C) at (0,0){};

\draw    ($($ (C.west)!.1!(C.east) $)-($(C.north)-(C.south)$)$)--($ (C.west)!.1!(C.east) $)
       --($ (C.west)!.25!(C.east) $)--($($ (C.west)!.3!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.4!(C.east) $)-(0,3pt)$)--($($ (C.west)!.5!(C.east) $)+(0,3pt)$)
       --($($ (C.west)!.6!(C.east) $)-(0,3pt)$)--($($ (C.west)!.7!(C.east) $)+(0,3pt)$)
       --($ (C.west)!.75!(C.east) $)--($ (C.west)!.9!(C.east) $)
       --($($ (C.west)!.9!(C.east) $)-($(C.north)-(C.south)$)$);
\end{tikzpicture}



\end{document}

相关内容