summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/pstricks/code/pst-coil.doc
blob: c412ed4595cf327d546aa5783d9491eef97e1e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
%% BEGIN pst-coil.doc
\def\fileversion{0.93a}
\def\filedate{93/03/12}
%%
%% For stroking and filling characters with PSTricks' line and fill styles.
%%
%% COPYRIGHT 1993, by Timothy Van Zandt, tvz@Princeton.EDU
%% See pstricks.doc or pstricks.tex for copying restrictions.
%%
%% See the PSTricks read-me file and the User's Guide for documentation.
%
% **************************************************************************
% This is `pst-coil.doc'. Use as is, or create a header file and stripped
% input file with pst-make.tex. See the PSTricks read-me file for details.
% **************************************************************************

\message{ v\fileversion, \filedate}

\csname PSTcoilsLoaded\endcsname
\let\PSTcoilsLoaded\endinput

\ifx\PSTricksLoaded\endinput\else
  \def\next{\input pstricks.tex}\expandafter\next
\fi

\edef\TheAtCode{\the\catcode`\@}
\catcode`\@=11

\pst@ATH<\% Version \fileversion, \filedate.>
\pst@ATH<\% For use with \pstdriver.>
\pst@ATH</tx@CoilDict 40 dict def tx@CoilDict begin>

\ifx\pst@useheader\iftrue
  \pstheader{pst-coil.pro}
  \edef\pst@theheaders{\pst@theheaders,pst-coil.pro}
  \def\pst@coildict{tx@CoilDict begin }
\else
  \def\pst@coildict{%
    /tx@CoilDict where
    { pop tx@CoilDict begin}
    { userdict begin /tx@CoilDict 40 dict def end
      tx@CoilDict begin }
    ifelse }
\fi

\def\psset@coilwidth#1{\pst@getlength{#1}\psk@coilwidth}
\psset@coilwidth{1cm}

\def\psset@coilheight#1{\pst@checknum{#1}\pscoilheight}
\psset@coilheight{1}

\def\psset@coilarmA#1{\pst@getlength{#1}\psk@coilarmA}
\def\psset@coilarmB#1{\pst@getlength{#1}\psk@coilarmB}
\def\psset@coilarm#1{%
  \pst@getlength{#1}\psk@coilarmA
  \let\psk@coilarmB\psk@coilarmA}
\psset@coilarm{.5cm}

\def\psset@coilaspect#1{\pst@getangle{#1}\psk@coilaspect}
\psset@coilaspect{45}

\def\psset@coilinc#1{\pst@getangle{#1}\psk@coilinc}
\psset@coilinc{10}

\def\pscoil{\def\pst@par{}\pst@object{pscoil}}
\def\pscoil@i{\pst@getarrows\pscoil@ii}
\def\pscoil@ii(#1){%
  \@ifnextchar(%
    {\pscoil@iii{1}(#1)}%
    {\pscoil@iii{\z@}(0,0)(#1)}}
\def\pscoil@iii#1(#2)(#3){%
  \begin@OpenObj
    \pst@getcoor{#2}\pst@tempa
    \pst@getcoor{#3}\pst@tempb
    \pst@optcp{#1}\pst@tempa
    \addto@pscode{%
      \pst@tempa \pst@tempb
      \psk@coilwidth \pscoilheight
      \psk@coilarmA \psk@coilarmB
      \psk@coilaspect \psk@coilinc
      \pst@coildict \tx@Coil end}%
     \showpointsfalse
  \end@OpenObj}

\pst@def{CoilLoop}<%
  /t ED
  t sin AspectSin mul t 180 div AspectCos mul add
  t cos
  lineto>

\pst@def{Coil}<%
  /Inc ED
  dup sin /AspectSin ED cos /AspectCos ED
  /ArmB ED /ArmA ED
  /h ED /w ED
  /y1 ED /x1 ED /y0 ED /x0 ED
  x0 y0 translate
  y1 y0 sub x1 x0 sub
  2 copy \tx@Pyth /TotalLength ED
  \tx@Atan rotate
  /BeginAngle ArmA AspectCos \tx@Div w h mul \tx@Div 360 mul def
  /EndAngle
    TotalLength ArmB sub AspectCos \tx@Div
    w h mul \tx@Div 360 mul
  def
  1 0 0 0 ArrowA
  ArmA 0 lineto
  /mtrx CM def
  w h mul 2 \tx@Div w 2 \tx@Div scale
  BeginAngle Inc EndAngle { \tx@CoilLoop } for
  EndAngle \tx@CoilLoop
  mtrx setmatrix
  TotalLength ArmB sub 0 lineto
  CP TotalLength 0 ArrowB
  lineto>

\def\psCoil{\def\pst@par{}\pst@object{psCoil}}
\def\psCoil@i#1#2{%
  \begin@AltOpenObj
    \showpointsfalse
    \pst@getangle{#1}\pst@tempa
    \pst@getangle{#2}\pst@tempb
    \addto@pscode{%
      \pst@tempa
      \pst@tempb
      \psk@coilwidth
      \pscoilheight
      \psk@coilaspect
      \psk@coilinc
      \pst@coildict \tx@AltCoil end
      \@nameuse{psls@\pslinestyle}}%
  \end@OpenObj}

\pst@def{AltCoil}<%
  /Inc ED
  dup sin /AspectSin ED cos /AspectCos ED
  /h ED /w ED
  /EndAngle ED /BeginAngle ED
  /mtrx CM def
  w h mul 2 \tx@Div w 2 \tx@Div scale
  BeginAngle sin AspectSin mul BeginAngle 180 div AspectCos mul add
  BeginAngle cos
  /lineto load stopped { moveto } if
  BeginAngle Inc EndAngle { \tx@CoilLoop } for
  EndAngle \tx@CoilLoop
  mtrx setmatrix>

\def\pszigzag{\def\pst@par{}\pst@object{pszigzag}}
\def\pszigzag@i{\pst@getarrows\pszigzag@ii}
\def\pszigzag@ii(#1){%
  \@ifnextchar({\pszigzag@iii{1}(#1)}{\pszigzag@iii{\z@}(0,0)(#1)}}
\def\pszigzag@iii#1(#2)(#3){%
  \begin@OpenObj
    \pst@getcoor{#2}\pst@tempa
    \pst@getcoor{#3}\pst@tempb
    \pst@optcp{#1}\pst@tempa
    \addto@pscode{%
      \pst@tempa
      \pst@tempb
      \pscoilheight
      \psk@coilwidth
      \psk@coilarmA
      \psk@coilarmB
      \pst@coildict \tx@ZigZag end
      \psline@iii
      \tx@Line}%
  \end@OpenObj}

\pst@def{ZigZag}<%
  /ArmB ED /ArmA ED
  2 div /w ED w mul /h ED
  /y1 ED /x1 ED /y0 ED /x0 ED
  x1 y1 translate
  y0 y1 sub x0 x1 sub
  2 copy \tx@Pyth /TotalLength ED
  \tx@Atan rotate
  TotalLength ArmA sub ArmB sub dup h div cvi /n ED
  n h mul sub 2 div dup ArmA add /ArmA ED ArmB add /ArmB ED
  /x ArmB h 2 div add def
  mark
  0 0 ArmB 0
  n { x w /w w neg def /x x h add def } repeat
  TotalLength ArmA sub 0 TotalLength 0>

\def\nccoil{\def\pst@par{}\pst@object{nccoil}}
\def\nccoil@i{\check@arrow{\nccoil@ii}}
\def\nccoil@ii#1#2{\nc@object{#1}{#2}{.5}{%
  \tx@NCCoor
    tx@Dict begin
    \psk@coilwidth \pscoilheight
    \psk@coilarmA \psk@coilarmB
    \psk@coilaspect \psk@coilinc
    \pst@coildict \tx@Coil end
   end}}

\def\pccoil{\def\pst@par{}\pst@object{pccoil}}
\def\pccoil@i{\pc@object\nccoil@ii}

\def\nczigzag{\def\pst@par{}\pst@object{nczigzag}}
\def\nczigzag@i{\check@arrow{\nczigzag@ii}}
\def\nczigzag@ii#1#2{\nc@object{#1}{#2}{.5}{%
  \tx@NCCoor
  tx@Dict begin
      \pscoilheight
      \psk@coilwidth
      \psk@coilarmA
      \psk@coilarmB
      \pst@coildict \tx@ZigZag end
      \psline@iii
      \tx@Line
  end}}

\def\pczigzag{\def\pst@par{}\pst@object{pczigzag}}
\def\pczigzag@i{\pc@object\nczigzag@ii}

\pst@ATH<end>

\catcode`\@=\TheAtCode\relax

\endinput
%% END pst-coil.doc