
次の例を考えてみましょう。
コード
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\begin{figure}
\psset{unit=0.05}
\begin{pspicture}(120,216)
\pnodes{P}(0,0)(0,120)(186,120)(216,120)(216,0)(186,0)(186,30)(186,90)
\pspolygon(P0)(P1)(P3)(P4)
\pcline[offset=12pt]{|<->|}(P1)(P3)
\ncput*[nrot=:U]{216}
\pcline[offset=12pt]{|<->|}(P3)(P4)
\ncput*[nrot=:U]{120}
\pspolygon[linestyle=none,fillstyle=vlines](P2)(P3)(P4)(P5)
\pswedge[linestyle=none,fillstyle=solid,fillcolor=white](P6){30}{270}{90}
\pswedge[linestyle=none,fillstyle=solid,fillcolor=white](P7){30}{270}{90}
\psarc(P6){30}{270}{90}
\psarc(P7){30}{270}{90}
\psdot(P6)
\psdot(P7)
\end{pspicture}
\end{figure}
\end{document}
出力
質問
上記のコードは、図を作成する間違った方法のようです。\pscustom
正しい方法だと思いますが、使用方法がわかりません。PSTricks を使用して「最適な」方法で図を作成するにはどうすればよいでしょうか? (これを使用するかあれを使用するかについてのコメントだけでなく、実際にどのように行われるかを見たいです。)
答え1
2 つのフレームと 2 つの円弧、または\pscustom
:
\documentclass{article}
\usepackage{pstricks-add}
\begin{document}
\psset{unit=1pt}
\begin{pspicture}(240,140)
\psframe[dimen=middle](216,120)
\psframe[fillstyle=vlines,linestyle=none](186,0)(216,120)
\psarc[fillstyle=solid,fillcolor=white](186,30){30}{-90}{90}
\psarc[fillstyle=solid,fillcolor=white](186,90){30}{-90}{90}
\psdots(186,30)(186,90)
\pcline[offset=12pt]{|<->|}(0,120)(216,120) \ncput*{216}
\pcline[offset=12pt]{|<->|}(216,120)(216,0) \ncput*[nrot=:U]{120}
\end{pspicture}
\begin{pspicture}(240,140)
\psframe[dimen=middle](216,120)
\pscustom[fillstyle=vlines,hatchcolor=red]{%
\psarc(186,30){30}{-90}{90}
\psarc(186,90){30}{-90}{90}
\psline(186,120)(216,120)(216,0)
}
\psdots(186,30)(186,90)
\pcline[offset=12pt]{|<->|}(0,120)(216,120) \ncput*{216}
\pcline[offset=12pt]{|<->|}(216,120)(216,0) \ncput*[nrot=:U]{120}
\end{pspicture}
\end{document}
\psframe
は閉じたパスを描画するので(適切なクリッピングに必要)、\pscustom
クリッピング関数を使用する場合は、 の最後のコンポーネントとして追加することもできます。
\documentclass{article}
\usepackage{pstricks-add}% http://tug.org/PSTricks/main.cgi/
\begin{document}
\begin{figure}
\psset{unit=1pt}
\begin{pspicture}(240,140)
\psclip{\psset{linestyle=solid}
\pscustom{
\psarc(186,30){30}{-90}{90}
\psarc(186,90){30}{-90}{90}
\psframe[dimen=middle](216,120)
}
}
\psframe[fillstyle=vlines,linestyle=none](186,0)(216,120)
\endpsclip
\psdots(186,30)(186,90)
\pcline[offset=12pt]{|<->|}(0,120)(216,120) \ncput*{216}% Top dimension
\pcline[offset=12pt]{|<->|}(216,120)(216,0) \ncput*[nrot=:U]{120}% Right dimension
\end{pspicture}
\end{figure}
\end{document}
これも構造と\psframe
描かれ方(中央左から反時計回り)により機能します。
答え2
既存の回答を改善しようとしています。
- 矢印指定子を に変更して、 -likeの先端を適切に揃える
|<->|
必要があります。|<*->|*
|
- デフォルトで設定されているすべてのコマンドにローカルに指定するよりも、グローバル
dimen=middle
に渡す方が適切です。\pscustom
dimen=outer
クリッピング領域はクリッパーパスをストロークした後に描画されるため、通常はクリッピング後に再度クリッパーパスをストロークする必要があります。
私の言っていることを理解したいなら、 Werner の編集で
hatchcolor=red,hatchsep=1pt
クリップしたものを追加しました。元々 Werner の設定では目立たないのですが、色の変更により、次のように「欠陥」が視覚的に明らかになりました。\psframe
hatchcolor=black
そのため、クリッピング後に再度ストロークする必要があります。
unit=1pt
ナビゲーション グリッドが乱雑になるため、使用は避けてください。
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-node}
\def\Path[#1]{%
\pscustom[dimen=middle,#1]{
\psarc(186,30){30}{-90}{90}
\psarc(186,90){30}{-90}{90}
\psframe(216,120)
}\ignorespaces
}
\begin{document}
\psset{unit=1pt,linewidth=3pt}
\begin{pspicture}(240,140)
\psclip{\Path[linestyle=none]}
\psframe[fillstyle=vlines,hatchcolor=red,hatchsep=1pt,linestyle=none](186,0)(216,120)
\endpsclip
\Path[]
\psdots(186,30)(186,90)
\pcline[offset=12pt]{|<*->|*}(0,120)(216,120) \ncput*{216}% Top dimension
\pcline[offset=12pt]{|<*->|*}(216,120)(216,0) \ncput*[nrot=:U]{120}% Right dimension
\end{pspicture}
\end{document}