为什么 \pscustom 无法填充封闭区域?

为什么 \pscustom 无法填充封闭区域?

在此处输入图片描述

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\def\Major{3}% semi major
\def\Minor{2}% semi minor
\def\Xo{4}% distance from origin to ellipse center
\def\Theta{60}


\pstVerb
{
    /Major \Major\space def
    /Minor \Minor\space def
    /Xo \Xo\space def
    /Theta \Theta\space def 
    /PtX1 180 Theta sub cos Major mul Xo add def
    /PtY1 180 Theta sub sin Minor mul def
    /PtX2 -180 cos Major mul Xo add def
    /PtY2 0 def
}

\begin{document}

\begin{pspicture}[showgrid](-\Major,-\Minor)(\Major,\Minor)
    \psset{linecolor=red}
    %\pscustom[fillstyle=solid,fillcolor=cyan]
    {%
        \pnode(!Xo 0){O}%
        \pnode(!PtX1 PtY1){A}%
        \pnode(!PtX2 PtY2){B}%      
        \psline(0,0)(0,0|A)(A)%
        \psellipticarc[correctAngle=true,origin={O}](O)(!Major Minor){(A)}{(B)}%
        \psline(B)(0,0)%
    }
\end{pspicture} 

\end{document}

编辑:我发现这里几乎有同样的问题,问题是我还是不明白 Herbert 在那里回答了什么。在 PSTricks 手册中,没有关于这些主题的详细解释。

答案1

我猜问题在于路径不是可以填充的连续路径。相反,它们是不同的线段,可能已填充但不会显示,因为结果是一维对象。

您可以放大以查看角落的问题。因此,修复该路径的顺序以使其不发生跳跃似乎是可行的。但我无法使语法正常{(A)}{(B)}工作。

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\def\Major{3}% semi major
\def\Minor{2}% semi minor
\def\Xo{4}% distance from origin to ellipse center
\def\Theta{60}

\pstVerb
{
    /Major \Major\space def
    /Minor \Minor\space def
    /Xo \Xo\space def
    /Theta \Theta\space def
    /Alpha 180 Theta sub def
    /PtX1 Alpha cos Major mul Xo add def
    /PtY1 Alpha sin Minor mul def
    /PtX2 Major neg Xo add def
    /PtY2 0 def
}
\begin{document}
\begin{pspicture}[showgrid](0,-1)(3,2)
    \psset{linecolor=red}
    \pnode(!Xo 0){O}
    \pnode(!PtX1 PtY1){A}
    \pnode(!PtX2 PtY2){B}
    \pscustom[fillstyle=solid,fillcolor=cyan]
    {
        \psline(B)(0,0)(0,0|A)(A)
        \psellipticarc[correctAngle=false](O)(!Major Minor){!Alpha}{180}
        \closepath
    }
\end{pspicture}
\end{document}

在此处输入图片描述

答案2

这就是答案!

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pstricks-add}

\def\Major{3}% semi major
\def\Minor{2}% semi minor
\def\Xo{4}% distance from origin to ellipse center
\def\Theta{60}


\pstVerb
{
    /Major \Major\space def
    /Minor \Minor\space def
    /Xo \Xo\space def
    /Theta \Theta\space def 
    /PtX1 180 Theta sub cos Major mul Xo add def
    /PtY1 180 Theta sub sin Minor mul def
    /PtX2 -180 cos Major mul Xo add def
    /PtY2 0 def
}

\begin{document}

\begin{pspicture}[showgrid](-\Major,-\Minor)(\Major,\Minor)
    \psset{linecolor=red}
    \pnode(!Xo 0){O}
    \pnode(!PtX1 PtY1){A}
    \pnode(!PtX2 PtY2){B} 
    \pnode(0,0){Origin}  
    \pscustom[fillstyle=solid,fillcolor=cyan,origin={O}]
    {
        \psline(Origin)(Origin|A)(A)
        \psellipticarc[dimen=middle](O)(!Major Minor){(A)}{(B)}%middle must be set!
        \closepath
    }
\end{pspicture} 

\end{document}

相关内容