\documentclass{article}
\usepackage{pstricks,pst-poly,pst-text,pst-key,graphicx,color}
\makeatletter
\SpecialCoor
\def\PstCoggedWheel#1#2{%
% #1 = number of teeth (it must be a divisor of 360!)
% #2 = height of the teeth, between 0 and 1 unit
\pst@cntc=360
\divide\pst@cntc by #1
\pst@cntd=\pst@cntc
\divide\pst@cntd\tw@
\pst@dimd=\psunit
\pssetlength{\pst@dimc}{#2}%
\advance\pst@dimd-\pst@dimc
\pscustom{%
\moveto(\pst@dimd;0)
\multido{\iAngleA=\z@+\pst@cntc,
\iAngleB=\pst@cntd+\pst@cntc,
\iAngleC=\pst@cntc+\pst@cntc}{#1}{%
\lineto(1;\iAngleA)
\lineto(1;\iAngleB)
\lineto(\pst@dimd;\iAngleB)
\lineto(\pst@dimd;\iAngleC)}}}
\makeatother
\begin{document}
\rput(-2,4){\PstCoggedWheel{9}{0.3}}
\rput(-2,1){\PstCoggedWheel{9}{7mm}}
\rput(-2,-3){\psset{unit=2,linecolor=red}\PstCoggedWheel{40}{0.1}}
\end{document}
答案1
答案2
pst-key
是旧包,请使用pst-xkey
。但是,仅使用\usepackage{pstricks,multido}
并且\SpecialCoor
不再需要,它是默认的。
\documentclass{article}
\usepackage{pstricks,multido}
\makeatletter
\def\PstCoggedWheel#1#2{%
[...]