答案1
像这样?
它不是画成pic
...我在我的答案集合中找到了这些图像,所以你的问题是重复的(不幸的是我没有记录问题)。
编辑:现在是更正的块名称和添加的第一个建议解决方案的限制说明
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[
node distance= 5mm,
block/.style = {
rectangle, draw, thick,
minimum height=9mm, minimum width=12mm,
},
sat/.style = {block,
append after command={
\pgfextra{\let\LN\tikzlastnode
\draw[gray]
($(\LN.south)+(0,1mm)$) edge ($(\LN.north)+(0,-1mm)$)
($(\LN.west) +(2mm,0)$) to ($(\LN.east) +(-2mm,0)$);
\draw[very thick, opacity=0.75]
($(\LN.south)+(-2mm, 2.5mm)$) -| (\LN.center) |-
($(\LN.north)+( 2mm,-2.5mm)$);
}% end \pgfextra
},% end after command
}
]
\node (X) [sat] at (0,0) {};
\end{tikzpicture}
\begin{tikzpicture}[
node distance = 5mm,
block/.style = {
rectangle, draw, thick,
minimum height=9mm, minimum width=12mm,
},
quant/.style = {block,
append after command={
\pgfextra{\let\LN\tikzlastnode
\draw[gray]
($(\LN.south)+(0,1mm)$) edge ($(\LN.north)+(0,-1mm)$)
($(\LN.west) +(2mm,0)$) to ($(\LN.east) +(-2mm,0)$);
\draw[thick, opacity=0.75]
($(\LN.center)+(-3.5mm,-3mm)$)
-| ++ (1mm,1mm) -| ++ (1mm,1mm) -| ++ (1mm,1mm)
-| ++ (1mm,1mm) -| ++ (1mm,1mm) -| ++ (1mm,1mm) -- ++ (1mm,0);
}% end \pgfextra
},% end after command
}
]
\node (X) [quant] at (0,0) {};
\end{tikzpicture}
\end{document}
笔记:
- 要使用上述块,您需要加载 tikz 库
calc
。 - 如果您喜欢彩色块,则解决方案不适用。选项覆盖块的内容。在这种情况下,最好
fill
使用:path picture=
append after command
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{calc, shadows}
\newcommand\ppbb{path picture bounding box} % <-- added
\begin{document}
\begin{tikzpicture}[
node distance= 5mm,
block/.style = {
rectangle, draw, thick,
minimum height=9mm, minimum width=12mm,
},
sat/.style = {block,
path picture={ % <-- changed
\draw[gray]
($(\ppbb.south)+(0,1mm)$) edge ($(\ppbb.north)+(0,-1mm)$)
($(\ppbb.west) +(2mm,0)$) to ($(\ppbb.east) +(-2mm,0)$);
\draw[very thick, opacity=0.75]
($(\ppbb.south)+(-2mm, 2.5mm)$) -| (\ppbb.center) |-
($(\ppbb.north)+( 2mm,-2.5mm)$);
}% end path picture
}
]
\node (X) [sat, fill=orange!10,drop shadow] at (0,0) {};
\end{tikzpicture}
\end{document}