避免路径图片中的线条剪切

避免路径图片中的线条剪切

Host我定义了一个像这样的节点样式(抱歉,是德语标签):

\tikzset{Host/.style={path picture={%
  \coordinate (hinten links oben) at ($(path picture bounding box.north west)!0.33!(path picture bounding box.north east)$);
  \coordinate (hp1) at ($(path picture bounding box.north west)!0.66!(path picture bounding box.north east)$);
  \coordinate (vorne links oben) at ($(path picture bounding box.south west)!0.66!(path picture bounding box.north west)$);
  \coordinate (vorne rechts unten) at ($(path picture bounding box.south west)!0.66!(path picture bounding box.south east)$);
  \coordinate (vorne rechts oben) at ($(vorne rechts unten)!0.66!(hp1)$);
  \coordinate (hinten rechts unten) at ($(path picture bounding box.south east)!0.33!(path picture bounding box.north east)$);
  \path (vorne links oben) edge [-] (hinten links oben);
  \path (hinten links oben) edge [-] (path picture bounding box.north east);
  \path (path picture bounding box.north east) edge [-] (hinten rechts unten);
  \path (hinten rechts unten) edge [-] (vorne rechts unten);
  \path (vorne rechts unten) edge [-] (path picture bounding box.south west);
  \path (path picture bounding box.south west) edge [-] (vorne links oben);
  \path (vorne links oben) edge [-] (vorne rechts oben);
  \path (vorne rechts oben) edge (path picture bounding box.north east) edge (vorne rechts unten);
}},minimum width=2em, minimum height=3em}

当我使用这种样式时,边界框边缘的线条看起来会更细。我认为这是因为线条“围绕”其定义端点“生长”,因此被边界框剪裁。

是否有一种简单的方法来插入某种边距?

答案1

作为快速修复,只需在路径图片边界框内移动当前线宽即可避免剪切。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\tikzset{Host/.style={path picture={%
\coordinate (ppbbnw) at ([shift={(.5\pgflinewidth,-.5\pgflinewidth)}]path picture bounding box.north west);
\coordinate (ppbbne) at ([shift={(-.5\pgflinewidth,-.5\pgflinewidth)}]path picture bounding box.north east);
\coordinate (ppbbsw) at ([shift={(.5\pgflinewidth,.5\pgflinewidth)}]path picture bounding box.south west);
\coordinate (ppbbse) at ([shift={(-.5\pgflinewidth,.5\pgflinewidth)}]path picture bounding box.south east);
\coordinate (hlo) at ($(ppbbnw)!{1/3}!(ppbbne)$);
\coordinate (hp1) at ($(ppbbnw)!{2/3}!(ppbbne)$);
\coordinate (vlo) at ($(ppbbsw)!{2/3}!(ppbbnw)$);
\coordinate (vru) at ($(ppbbsw)!{2/3}!(ppbbse)$);
\coordinate (vro) at ($(vru)!{2/3}!(hp1)$);
\coordinate (hru) at ($(ppbbse)!{1/3}!(ppbbne)$);
\draw (ppbbne) -- (hru) -- (vru) -- (ppbbsw) -- (vlo) -- (hlo) -- cycle;
\draw (vlo) --(vro) -- (ppbbne) (vro) -- (vru);
}
},minimum width=2em, minimum height=3em}

\node[Host,thick] {};
\node[Host,ultra thin] at (1,0) {};
\node[Host] at (2,0) {};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容