PSTricks로 클리핑

PSTricks로 클리핑

다음 예를 고려하십시오.

암호

\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

두 개의 프레임과 두 개의 호 또는 \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

기존 답변을 개선하려고 노력하고 있습니다.

  • - 같은 팁을 적절하게 정렬 하려면 화살표 지정자를 |<->|로 변경해야 합니다 .|<*->|*|
  • 기본적으로 모든 단일 명령에 로컬로 지정하는 것보다 전역적 dimen=middle으로 전달하는 것이 더 좋습니다 .\pscustomdimen=outer
  • 클리퍼 경로를 스트로크한 후 클리퍼 영역을 그리므로 일반적으로 클리핑 후 다시 클리퍼 패스를 스트로크해야 합니다.

    내가 의미하는 바를 이해하고 싶다면 Werner의 편집 내용에 hatchcolor=red,hatchsep=1pt잘린 부분을 추가했습니다. \psframe원래 Werner의 설정은 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}

관련 정보