%3F.png)
draw=none
TikZ のキーと値のペアとの違いは何ですかdraw opacity=0
? それらは機能的に同等ですか、それとも一方を他方よりも優先すべき状況がありますか? 同様に、fill=none
との違いは何ですかfill opacity=0
?
答え1
draw=none
(これはコマンドと同じです\path
) は、実際には TikZ に構築されたパスを破棄させ、境界ボックスは乱されません(ナンセンスです。境界ボックスは変更されますが、line width
無視されるだけです。この愚かさに気付いてくださった @Fritz に感謝します)。
draw opacity=0
ただし、パスはインクなしで描画されるため、境界ボックスはline width
オプションが有効になった状態で更新され、境界ボックスの計算では線のスタイルが重要になります。
\begin{tikzpicture}
\draw (0,0) rectangle (3,3);
\draw[opacity=0,line width=1cm] (0,0) rectangle (3,3); % Enlarge the bounding box
\pgfsetlinewidth{5cm} % this has no effect
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{4cm}{4cm}} % this updates the known max x,y coordinates!!
\pgfusepath{} % even though it's thrown away.
\begin{pgfinterruptboundingbox}
\pgfpathmoveto{\pgfpointorigin}
\pgfpathlineto{\pgfpoint{10cm}{10cm}} % Nothing happens
\pgfusepath{}
\end{pgfinterruptboundingbox}
\draw[dashed,thin] (current bounding box.north east) rectangle (current bounding box.south west);
\end{tikzpicture}
答え2
filling opacity
は塗りつぶし操作だけでなく、テキストや画像にも適用されます。次の例は、fill=none
とfill opacity=0
(実際にはfill opacity=0.2
テキストを表示するためにのみ使用) が異なる結果を生成するケースを示しています。fill=none
ノード ラベルには影響しませんが、fill opacity=<value>
テキストには影響します。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[olive] (0,0) rectangle (3,2);
\node[fill opacity=0.2] at (3,2) {\huge B};
\node[fill=none] at (0,0) {\huge A};
\end{tikzpicture}
\end{document}