我想在我的 tikzset 中添加一个积分三角形。我的意思如图所示;
如您所见,它仅由一个矩形和一个三角形组成。我希望它能像此 tikzset 中的其他节点一样工作;
\tikzset{
block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em},
tmp/.style = {coordinate},
sum/.style = {draw, fill=white, circle, node distance=1cm},
input/.style = {coordinate},
output/.style = {coordinate},
pinstyle/.style = {pin edge={to-, thin, black}},
transfer_func/.style= {draw, fill=white, rectangle}
}
有人能帮我制作一种称为积分器的样式吗?其中输入节点如图所示,输出节点是三角形的尖端。如果有帮助的话,我制作了正确的形状,但不知道如何让它作为节点工作,也不知道如何修复输出,以便可以进一步使用它来创建框图。
integrator/.style = {to path={(\tikztostart) -- ++(0,0.55) -- ++(0.2, 0) -- ++(0.7, -0.55) -- ++(-0.7, -0.55) -- ++(0,1.1) -- ++(0, -1.1) -- ++(-0.2, 0) -- (\tikztotarget) cycle}}
答案1
像这样:
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
quotes,
}
\begin{document}
\begin{tikzpicture}[
INT/.style = {
rectangle, draw, semithick, outer sep=0pt,
minimum height=12mm, minimum width=3mm,
append after command={\pgfextra{\let\LN\tikzlastnode
\draw[semithick, line cap=round]
(\LN.north east) -- ++ (9mm,-6mm) coordinate (\LN-out)
-- (\LN.south east);
\coordinate (\LN-in) at (\LN.west);
}% end after command
},% end after command
node contents= {}
}% end of IN T
]
\node (X) [INT];
%
\draw[red] (X-out) to["$\int u\,dt$"] ++ (1,0);
\draw[Straight Barb-,blue] (X-in) to ["$u(t)$" '] ++ (-1,0);
\end{tikzpicture}
\end{document}
答案2
这是一个不寻常的解决方案,它包含
integrator angle
可以设置三角形角度的值键,箭头尖端
Integrator Cap
使用上述值,以便它正好适合三角形的尖端,并且integrator
选择形状、single arrow
设置一些尺寸并使用的样式integrator angle
。此样式还临时将垂直线添加到形状定义中。它可能需要根据不同的
outer ysep
设置进行调整,但很少会改变。
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{arrows.meta, shapes.arrows}
\makeatletter
\tikzset{
integrator angle/.initial=60,
Integrator Cap/.tip={
Triangle Cap[cap angle=\pgfkeysvalueof{/tikz/integrator angle}, reversed,
sep=+0pt -.5/tan(.5*(\pgfkeysvalueof{/tikz/integrator angle}))]},
integrator/.style={
shape=single arrow, draw, minimum height=+7.5mm, minimum width=+10mm,
single arrow tip angle=\pgfkeysvalueof{/tikz/integrator angle},
single arrow head extend=+0pt,
/utils/exec=% outer seps are usually .5\pgflinewidth and are rarely changed
\pgfutil@namedef{pgf@sh@fbg@single arrow}{% fbg is the before background path
\pgfsetbuttcap % force butt cap,
\pgfpathmoveto{\pgfpointadd{\pgf@sh@reanchor{single arrow}{before head}}
{\pgfpoint{+.5\pgflinewidth}{-(\pgfkeysvalueof{/pgf/outer ysep})}}}%
\pgfpathlineto{\pgfpointadd{\pgf@sh@reanchor{single arrow}{after head}}
{\pgfpoint{+.5\pgflinewidth}{\pgfkeysvalueof{/pgf/outer ysep})}}}%
\pgfusepathqstroke}}} % no arrow tip, no shortening, no corners
\makeatother
\begin{document}
\tikz[ultra thick, >=Stealth]
\node[integrator, draw=red, fill=blue!50]{}
edge[<-] +(left:1)
edge[Integrator Cap->] +(right:1.5);
\end{document}