我想将代码从 pgf 基础层转换到 pgf 系统层。我的第一个代码是:
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
a\fbox{\begin{tikzpicture}
\pgftransformscale{.025}%
\pgfpathmoveto{\pgfqpoint{71.43 bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{332.57bp}}
\pgfpathlineto{\pgfqpoint{428.57bp}{214.29bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{96.00 bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{189.71bp}}
\pgfpathlineto{\pgfqpoint{71.43 bp}{189.71bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\pgfpathmoveto{\pgfqpoint{453.14bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{46.86 bp}}
\pgfpathlineto{\pgfqpoint{453.14bp}{46.86 bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\end{tikzpicture}}b
\end{document}
我得到了我想要的:
现在有了 pgf 系统层,我有了下一个代码,但我不知道如何添加边界框
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document}
\makeatletter
a\fbox{\begin{tikzpicture}
\pgfsys@transformxyscale{.025}{.025}
\pgfsys@fill
\pgfsys@moveto{71.43bp}{238.86bp}
\pgfsys@lineto{310.29bp}{238.86bp}
\pgfsys@lineto{310.29bp}{332.57bp}
\pgfsys@lineto{428.57bp}{214.29bp}
\pgfsys@lineto{310.29bp}{96.00bp}
\pgfsys@lineto{310.29bp}{189.71bp}
\pgfsys@lineto{71.43bp}{189.71bp}
\pgfsys@closepath
\pgfsys@fillstroke
\pgfsys@fill
\pgfsys@moveto{453.14bp}{381.71bp}
\pgfsys@lineto{500.00bp}{381.71bp}
\pgfsys@lineto{500.00bp}{46.86bp}
\pgfsys@lineto{453.14bp}{46.86bp}
\pgfsys@closepath
\pgfsys@fillstroke
\end{tikzpicture}}b
\end{document}
不幸的是,结果是
如何获得同样的结果?
答案1
问题似乎在于命令的不一致
\pgfsys@transformxyscale{0.025}{0.025}
和
\pgftransformscale{.025}
正如您很好地演示的那样,后一个命令实际上位于基本层中,并且不会对画布本身起作用。但是,如果我将其设置为系统层转换,使其适用于所有内容,我就会得到糟糕的绘图。以下是我所做的:
\documentclass{article}
\usepackage{tikz}
\begin{document}
a\fbox{\begin{tikzpicture}
\pgflowlevel{\pgftransformscale{.025}}%
\pgfpathmoveto{\pgfqpoint{71.43 bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{238.86bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{332.57bp}}
\pgfpathlineto{\pgfqpoint{428.57bp}{214.29bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{96.00 bp}}
\pgfpathlineto{\pgfqpoint{310.29bp}{189.71bp}}
\pgfpathlineto{\pgfqpoint{71.43 bp}{189.71bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\pgfpathmoveto{\pgfqpoint{453.14bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{381.71bp}}
\pgfpathlineto{\pgfqpoint{500.00bp}{46.86 bp}}
\pgfpathlineto{\pgfqpoint{453.14bp}{46.86 bp}}
\pgfpathclose
\pgfusepath{fill,stroke}%
\end{tikzpicture}}b
\makeatletter
\end{document}
这给出了
因此,我们需要找到命令的实际低级等价物\pgftransformscale{}
。我曾尝试找到直接句柄,但似乎相对坐标变换在系统层处理起来并不那么简单。我可以看到单位向量是\edef
在文件中编辑的pgfcoretransformation.code.tex
,所以我不抱太大希望(但我的知识与文档中的内容一致,我可能错了)。