答案1
如果您确实需要一个恒定的距离,则缩放图形是行不通的,但您可以使用此处给出的解决方案: https://tex.stackexchange.com/a/103088/8650
该解决方案仅适用于开放路径,因此我像这样关闭一侧的路径:
\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations}
\def\pgfdecoratedcontourdistance{0pt}
\pgfkeys{/pgf/decoration/contour distance/.code={%
\pgfmathparse{#1}%
\let\pgfdecoratedcontourdistance=\pgfmathresult}%
}
\pgfdeclaredecoration{contour lineto}{start}
{
\state{start}[next state=draw, width=0pt]{
\pgfpathmoveto{\pgfpoint{0pt}{\pgfdecoratedcontourdistance}}%
}
\state{draw}[next state=draw, width=\pgfdecoratedinputsegmentlength]{
\pgfmathparse{-\pgfdecoratedcontourdistance*cot(-\pgfdecoratedangletonextinputsegment/2+90)}%
\let\shorten=\pgfmathresult%
\pgfpathlineto{\pgfpoint{\pgfdecoratedinputsegmentlength+\shorten}{\pgfdecoratedcontourdistance}}%
}
\state{final}{
\pgfpathlineto{\pgfpoint{\pgfdecoratedinputsegmentlength}{\pgfdecoratedcontourdistance}}%
}
}
\begin{document}
\begin{tikzpicture}
\draw [postaction={decoration={contour lineto, contour distance=-4pt}, draw, densely dashed, decorate}]
(0,0.5) -- (0,1) -- (0.5, 1.5) -- (1,1) -- (1,0) -- (0,0) --cycle ;
\end{tikzpicture}
\end{document}
为了表明形状不仅仅是缩放,这里是距离较大的相同图形:
可以看出,内部形状与外部形状并不相同。