避免路徑圖片中的線條剪切

避免路徑圖片中的線條剪切

我定義了這樣的節點樣式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}

在此輸入影像描述

相關內容