我有以下代码,它应该给我一个 NAND 门:
\tikzset{
block rect/.style =
{
draw = \linecolor,
fill = \blockcolor,
rectangle,
minimum height = 1.6\blocksize,
minimum width = \blocksize,
anchor = center,
inner sep = 0.05\blocksize,
font = \blockfontsize
},
nand gate/.style =
{
draw,
block rect,
yshift = -0.33\blocksize,
append after command =
{
\pgfextra
{%
\node [draw, circle, minimum size = 1mm, inner sep=0pt] at ([xshift=0.5mm]\tikzlastnode.east) {};
}
},
path picture =
{
\node at ([yshift=0.33\blocksize]path picture bounding box.center) {\small \&};
}
}}
它确实有效并且给了我一个很好的(欧式风格:-))NAND门:
但是,当我想将 NAND 门的输出与 (节点名称.east) 一起使用时,实际的东锚点是矩形的东锚点,但我想将东锚点向右移动小圆直径的距离。否则,来自 NAND 右侧的任何连接都会穿过该小圆,这是错误的,而且看起来很难看。
其次,我想在 NAND 的左侧为两个输入端口添加两个额外的锚点“in1”和“in2”或“a”和“b”,这样我就可以将线连接到 NAND 的输入。这两个锚点应位于矩形高度的 +/-0.33 处。我该如何为我的门定义这两个新锚点?
答案1
带有图书馆的一个小例子circuits
TikZ
。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{circuits.logic.IEC}
\begin{document}
\begin{tikzpicture}[circuit logic IEC, huge circuit symbols]
\matrix[column sep=10mm]
{
\node [nand gate] (nand) {}; & & \\
& \node [nor gate, inputs=nni] (nor) {}; &
\node [or gate, inputs=nnn] (out) {}; \\
};
\node (c) at ([xshift=-10mm]nand.west|-nor.input 2) {C};
\draw (nor.input 2) -- (c);
\draw (nand.input 2) -- (nand.input 2-|c.east) node[left] (b) {B};
\draw (nand.input 1) -- (nand.input 1-|c.east) node[left] (a) {A};
\draw (nor.input 3) -- coordinate (Daux) (nor.input 3 -|c.east) node[left] (d) {D};
\draw (out.input 3) -| ([shift={(-5mm,-5mm)}]out.input 3) -| (Daux);
\draw (out.input 1) --++(180:5mm) |- (nand.output);
\draw (nor.input 1) --++(180:5mm) |- (nand.output);
\draw (nor.output) -- ++(right:5mm) |- (out.input 2);
\draw (out.output) -- ++(right:10mm);
\end{tikzpicture}
\end{document}