如何使 \reversepath 對於繪製以下閉合曲線有用?

如何使 \reversepath 對於繪製以下閉合曲線有用?

我想畫一個蝙蝠俠標誌。由於它是關於垂直線對稱的,所以先定義右側部分(或左側部分),然後反映它以獲得另一部分應該會更方便。您必須考慮的重要注意事項是徽標必須由可用作剪切路徑的閉合曲線建構。

根據pst-news13第 4 頁,我們\reversepath可以使用它來建構反向座標中的曲線。

不幸的是,我未能使用\reversepath如下程式碼所示。

\documentclass[pstricks,border=6pt]{standalone}
\SpecialCoor

\pstVerb
{
    /theta 72 def
    /Major 6.0 def
    /Minor 3.3 def
    % b a t p2c ---> x y
    % where b (semi-minor), a (semi-major), t (theta)
    /p2c {dup 3 1 roll cos mul 3 1 roll sin mul} bind def
}


\def\RightPart
{
    \psline(0,2.7)(0.5,2.7)(1,3.25)
    \psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
    \psbezier(3.0,1.0)(3.0,2.2)(!Minor Major theta p2c)
    \psellipticarcn(0,0)(!Major Minor){(!Minor Major theta p2c)}{(!Minor Major theta neg p2c)}
    \psbezier(4,-2)(4,0)(2.2,-1.8)
    \psbezier(1.5,-1)(1,-1)(0,-3.2)
}

\def\LeftPart
{
    \scale{-1 1}
    \reversepath
    \psbezier(1.5,-1)(1,-1)(0,-3.2)
    \psbezier(4,-2)(4,0)(2.2,-1.8)
    \psellipticarcn(0,0)(!Major Minor){(!Minor Major theta p2c)}{(!Minor Major theta neg p2c)}
    \psbezier(3.0,1.0)(3.0,2.2)(!Minor Major theta p2c)
    \psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
    \psline(0,2.7)(0.5,2.7)(1,3.25)
    \closepath
}


\begin{document}
\begin{pspicture}[showgrid=false](-7.85,-4.85)(7.85,4.85)
    \pscustom[dimen=middle]{\RightPart}
\end{pspicture}
\begin{pspicture}[showgrid=false](-7.85,-4.85)(7.85,4.85)
    \pscustom[dimen=middle]{\LeftPart}
\end{pspicture}
\begin{pspicture}[showgrid=false](-7.85,-4.85)(7.85,4.85)
    \pscustom[dimen=middle,fillstyle=solid,fillcolor=red]{\RightPart\LeftPart}
\end{pspicture}
\end{document}

在此輸入影像描述

\reversepath所以我的問題是如何在這種情況下使用?

答案1

在花了很多時間來弄清楚它是如何\reversepath運作的之後,現在它的行為已經被理解了。

\reversepath影響之前的路徑而不是之後的路徑(大多數人可能認為)。它的行為與為 定義的其他巨集(例如\scale\translate等)不一致pscustom。這是 PSTricks 中許多其他不一致之處之一。但它仍然很有趣!

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


% b a t p2c ---> x y
% where b (semi-minor), a (semi-major), t (theta)
\pstVerb{/p2c {dup 3 1 roll cos mul 3 1 roll sin mul} bind def}


\def\RightPart
{
    \psline(0.5,2.7)(1,3.25)
    \psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
    \psbezier(3.0,1.0)(3.0,2.2)(!3.3 6.0 72 p2c)
    \psellipticarcn(6.0,3.3){(!3.3 6.0 72 p2c)}{(!3.3 6.0 72 neg p2c)}
    \psbezier(4,-2)(4,0)(2.2,-1.8)
    \psbezier(1.5,-1)(1,-1)(0,-3.2)
}


\begin{document}

\begin{pspicture}[showgrid](-7,-4)(7,4)
\pscustom[dimen=middle,fillstyle=solid,fillcolor=orange,linewidth=6pt]
{
    \RightPart
    \reversepath
    \scale{-1 1}
    \RightPart
    \closepath
}
\end{pspicture}
\end{document}

在此輸入影像描述

相關內容