我目前正在尝试对由坐标和循环列表构建的路径进行一些修饰。我在循环的结束点观察到一个奇怪的结果。我正在寻找解决方案来消除它。
平均能量损失
\documentclass{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{trees,decorations}
\begin{document}
\begin{tikzpicture}[]
\coordinate (K) at (3,1);
\coordinate (of) at (7,1.5);
%\draw[help lines] (0,0) grid (10,5);
\draw[decorate,black,decoration={curveto,raise=-10pt}] (K) plot [smooth cycle,tension=0.7] coordinates {(3,1) (5,1.2) (7,1) (8,3) (7,4.5) (5,4.5) (2,4) (1.7,2.5)};
\draw[black] (K) plot [smooth cycle,tension=0.7] coordinates {(3,1) (5,1.2) (7,1) (8,3) (7,4.5) (5,4.5) (2,4) (1.7,2.5)};
\end{tikzpicture}
\end{document}
答案1
\documentclass[border=9,tikz]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}
\makeatletter
\pgfdeclaredecoration{raise close}{start}{
\state{start}[width=+0pt,next state=iterate,persistent precomputation=\pgfdecoratepathhascornerstrue]
{\pgfpathmoveto{\pgfpoint{0pt}{\pgfdecorationsegmentamplitude}}}
\state{iterate}[width=+\pgfdecorationsegmentlength]{\pgfpathlineto{\pgfpoint{0pt}{\pgfdecorationsegmentamplitude}}}
\state{final}{\pgfpathclose}
}
\pgfdeclaredecoration{raise open}{start}{
\state{start}[width=+0pt,next state=iterate,persistent precomputation=\pgfdecoratepathhascornerstrue]
{\pgfpathmoveto{\pgfpoint{0pt}{\pgfdecorationsegmentamplitude}}}
\state{iterate}[width=+\pgfdecorationsegmentlength]{\pgfpathlineto{\pgfpoint{0pt}{\pgfdecorationsegmentamplitude}}}
\state{final}{}
}
\tikz{
\draw[decorate,decoration={raise close,amplitude=-10pt,segment length=1pt}]
plot[smooth cycle,tension=.7]coordinates{(3,1)(5,1.2)(7,1)(8,3)(7,4.5)(5,4.5)(2,4)(1.7,2.5)};
\draw plot[smooth cycle,tension=.7]coordinates{(3,1)(5,1.2)(7,1)(8,3)(7,4.5)(5,4.5)(2,4)(1.7,2.5)};
}
\tikz{
\draw[double,double distance=10pt]
plot[smooth cycle,tension=.7]coordinates{(3,1)(5,1.2)(7,1)(8,3)(7,4.5)(5,4.5)(2,4)(1.7,2.5)};
}
\end{document}