我可以在 tikz 中做这样的事情,但是我该如何定义\wd
形状宽度?
\makeatletter
\pgfdeclareshape{myshape}{%
\inheritsavedanchors[from=rectangle]%
\inheritanchorborder[from=rectangle]%
\inheritanchor[from=rectangle]{center}%
%
\backgroundpath{%
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
\pgfpathmoveto{\pgfpoint{\pgf@xa+0.5\wd}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
}%
}
\makeatother
答案1
嗯,这似乎有效:我可以将东北点的坐标添加到西南点的负数中。
\newdimen{\pgf@dx}
\pgfextractx{\pgf@dx}{\pgfpointadd{\northeast}{\pgfpointscale{-1}{\southwest}}}
答案2
官方获取宽度的方法如下
\southwest% \pgf@xa=\pgf@x% \northeast% \advance\pgf@x by-\pgf@xa%
我之所以打电话给官员,是因为你可以在pgfmoduleshapes.code.tex
1036-1040 行看到它
要获得北锚,最短的方法是
\southwest% \pgf@xa=.5\pgf@x% \northeast% \advance\pgf@xa by.5\pgf@x%