我正在尝试填充 pstricks 中的一些自定义区域,结果让我有点惊讶。这是我的 MWE:
\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3,-2.3)(3,3)
\psclip[linestyle=none]{%
\pscustom{
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
}}
\psframe*[linecolor=gray,opacity=0.6](-3,-3)(3,3)
\endpsclip
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\begin{pspicture}(-3,-2.3)(3,3)
\pscustom[fillstyle=solid,fillcolor=gray]{
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
}
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\begin{pspicture}(-3,-2.3)(3,3)
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\end{document}
结果如下:
我想要填充的形状显示在右侧。左侧和中间显示了两次填充形状的不同尝试的结果。不仅两次都不能精确填充形状,而且不匹配还取决于我是否\psclip
直接使用\pscustom
。这是为什么呢?
答案1
在\pscustom
里面最后的直线/曲线(路径)的点是总是这第一的 以下曲线(路径)的点!例如:
\pscustom{%
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
...
错了!第二个\pscurve
现在有四对坐标:
\pscurve(2.5,-2)(2.5,-2)(0.9,0)(0,2)
这与删除第一个点的曲线有很大不同\pscurve(2.5,-2)(0.9,0)(0,2)
,一切都会好起来!
\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3,-2.3)(3,3)
\psclip[linestyle=none]{%
\pscustom{
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(0.9,0)(0,2)
\pscurve(-0.9,0)(-2.5,-2)
}}
\psframe*[linecolor=gray,opacity=0.6](-3,-3)(3,3)
\endpsclip
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\begin{pspicture}(-3,-2.3)(3,3)
\pscustom[fillstyle=solid,fillcolor=gray]{
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(0.9,0)(0,2)
\pscurve(-0.9,0)(-2.5,-2)
}
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\begin{pspicture}(-3,-2.3)(3,3)
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\end{document}
以下两条曲线没有区别:
\documentclass[border=3mm]{standalone}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-3,-2.3)(3,3)
\pscustom[linewidth=4pt,linecolor=blue]{
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(0.9,0)(0,2)
\pscurve(-0.9,0)(-2.5,-2)
\closepath
}
\psset{linecolor=red,linewidth=1.5pt}
\pscurve(-2.5,-2)(0,-1.5)(2.5,-2)
\pscurve(2.5,-2)(0.9,0)(0,2)
\pscurve(0,2)(-0.9,0)(-2.5,-2)
\end{pspicture}
\end{document}