-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxodraw4j.sty
More file actions
2501 lines (2466 loc) · 68.4 KB
/
axodraw4j.sty
File metadata and controls
2501 lines (2466 loc) · 68.4 KB
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\ProvidesPackage{axodraw4j}[2008/11/19]
\typeout{Document option: axodraw4j. 19 Nov 2008}
\typeout{***************************************************************************}
\typeout{WARNING: use of axodraw4j is recommended only in conjunction with JaxoDraw!}
\typeout{.....See http://jaxodraw.sourceforge.net/ for information on JaxoDraw......}
\typeout{***************************************************************************}
% Style file for the drawing of Feynman diagrams with LaTeX.
% It assumes that the dvips that is used is by Radical Eye Software
% (by Rokicki), because the graphics primitives are given in
% postscript. If you do not work with a dvi to postscript converter
% you are out of luck.
%
% Original version made by J.A.M. Vermaseren 14-feb-1994
% Current version maintained by John Collins
% collins at phys dot psu dot edu
% with code by Daniele Binosi and Lukas Theussl.
% Copyright J.A.M. Vermaseren, John Collins, Daniele Binosi and Lukas
% Theussl (1994-2008).
%% This package may be distributed under the terms of the LaTeX Project Public
%% License, as described in lppl.txt in the base LaTeX distribution.
%% Either version 1.0 or, at your option, any later version.
% Use:
% Enter the picture environment with for instance
% \begin{picture}(width,height)(0,0)
% statements
% \end{picture}
% All statements should be entered inside the picture environment.
% All coordinates should be in terms of pt (but the pt must be omitted).
% One may also use the figure environment.
% Issues:
% 1. a. Global scaling: axoscale applies to graphics, but not to
% text
% b. Text uses \unitlength, but graphics does not
% c. Drawing of postscript works in (postscript) points,
% but picture works in terms of \unitlength, which by
% default coincide.
% d. Note that \SetScale{4}\setlength{\unitlength}{4pt}
% appears to work appropriately: graphics and positions
% are scaled, but text size is unscaled.
% e. User could legitimately set \unitlength, since that
% is documented for the picture environment. But AXO
% drawings should be insulated from that, or they
% should consistently use \unitlength
% f. Perhaps there should be an axopicture environment,
% which is picture environment which sets \unitlength
% to 1pt? Done
% 2. Need \GluonBezier and \PhotonBezier. Could use code in
% JD for the drawing routines. See JaxoGlBezier.java,
% and JaxoPBezier.java. Not urgent, since JD does
% implement them in some way.
\RequirePackage{keyval}
% Ideas from usenet message on comp.text.tex, Alberto L 29 Oct 2004.
\IfFileExists{colordvi.sty}{
\RequirePackage{colordvi} % For colorname macros like \Black
% This is used by jaxodraw when it invokes
% axodraw
\background{White}
\textBlack
\def\axocolor{Black }
\def\SetColor##1{\def\axocolor{##1 }}
\def\IfColor##1##2{##1}
}{
% Fixups in case of absence of colordvi.sty
\def\axocolor{ }
\def\SetColor##1{\def\axocolor{ }}
\def\Color##1##2{##2}
\def\IfColor##1##2{##2}
}
\input{rotate}
%=========================================================
% Commands to set parameters
%
% Arrow scale:
\newcommand{\AXO@DefaultArrowScale}{1}
\newcommand\SetArrowScale[1]{%
\renewcommand\AXO@DefaultArrowScale{#1}%
}
% Alternative name
\newcommand\DefaultArrowScale[1]{\SetArrowScale{#1}}
\SetArrowScale{1}
% Arrow inset:
\newcommand\AXO@ArrowInset{0.2}
%\renewcommand\AXO@ArrowInset{-1 }
\newcommand\SetArrowInset[1]{%
\renewcommand\AXO@ArrowInset{#1}%
}
% Arrow aspect:
\newcommand\AXO@DefaultArrowAspect{1.25}
\newcommand\SetArrowAspect[1]{%
\renewcommand\AXO@DefaultArrowAspect{#1}%
}
% Arrow position (fractional position along line):
\newcommand\AXO@ArrowPos{0.5}
\newcommand\SetArrowPosition[1]{%
\renewcommand\AXO@ArrowPos{#1}%
}
% Arrow stroke width
\newcommand{\AXO@DefaultArrowStroke}{1}
\newcommand\SetArrowStroke[1]{%
\renewcommand\AXO@DefaultArrowStroke{#1}%
}
%=========================================================
%=========================================================
%=========================================================
%================= PostScript preamble
\AtBeginDvi{
% This forces the PostScript preamble commands to be put into the
% dvi file. Without this, revtex4 can remove them by funny
% stuff with manipulating the first page.
%
% #[ inventory :
%
% The variables in here are:
% num,num1,ampi,ampi1,x1,y1,x2,y2,x3,y3,x4,y4,dx,dy,dr
% width, arrowpos, arrowspec, arrowwidth, arrowlength, arrowinset
% arcend, arcmid, arcstart, radius, linesep, angdsize, dsize,
% clockwise, dotsize, inc, pi, sign
% darc,const,amp1, amp2, amp3, amp4, amp5, amp6, amp7, amp8, amp1i
% gcolor,xx2
%
% NOTE: blank lines are not allowed inside the postscript code!!!!!
% (LaTeX sneaks \par commands in and the postscript goes boink)
%
\special{color} % Provoke dvips into including color.pro
% Revtex4 in 2-column mode fails to force that
\special{!
/pi 3.141592 def
/ed{exch def}def
/gs{gsave dup scale}def
/gsw{ gs
/width ed
width setlinewidth
}def
/p1{/y1 ed /x1 ed}def
/p2{/y2 ed /x2 ed}def
/p3{/y3 ed /x3 ed}def
/p4{/y4 ed /x4 ed}def
/garrow{/arrowpos ed /arrowspec ed}def
/setabs{
% Usage /var setabs
% Sets variable to its absolute value
dup load abs def
}def
%
/normalizearc {
% Usage: clockwise r angle1 angle2 x y normalizearc
% Adjusts coordinate system for anticlockwize arc from angle
% zero, centered at origin.
% Left on stack: r d_angle, with 0<d_angle <=360.
% Zero angle arc converted to loop
translate
exch dup rotate % Origin of arc now at angle 0
sub % Change angle2 to dangle
3 2 roll
{ % Clockwise arc: obtain from anticlockwise arc
neg
1 -1 scale
} if
dup abs 360 ge
{ %Outside 360 degrees, make exactly a loop
pop 360
}
{ % Convert to positive angle mod 360.
dup
dup 0 lt { 360 sub } if
360 div truncate 360 mul sub
dup 0.1 lt { pop 360 } if
}ifelse
} def
%
/normalizeline {
% Usage: x1 y1 x2 y2 normalizeline
% Adjusts coordinate system for line from origin in x direction
% Left on stack: dr = length of line
3 index 3 index translate
2 index sub exch 3 index sub
2 copy atan rotate
dup mul exch dup mul add sqrt
3 1 roll pop pop
} def
%
/abox{
newpath
x1 y1 moveto
x1 y2 lineto
x2 y2 lineto
x2 y1 lineto
closepath
}def
/atriangle{
newpath
x1 y1 moveto
x2 y2 lineto
x3 y3 lineto
closepath
}def
/abezier{
newpath
x1 y1 moveto
x2 y2 x3 y3 x4 y4 curveto
}def
/distance{
% Usage: x1 y1 x2 y2 distance -> x1 y1 x2 y2 r
% Pure stack based: computes distance between points. Keeps points
dup
3 index sub dup mul
2 index 5 index sub dup mul add sqrt
} def
}
%
% #] inventory :
%
%============================================================
%============================================================
%
% Define better arrows
%
\special{!
% Arrow making routines
%
% Arrow drawing:
%
/arrowVTriangle {
% Down-pointing arrow: arrowstroke width length inset arrowVTriangle
/arrowinset ed
/arrowlength ed
/arrowwidth ed
/arrowstroke ed
newpath
0 arrowlength -0.5 mul moveto
arrowwidth arrowlength rlineto
arrowwidth -1 mul arrowlength arrowinset mul -1 mul rlineto
arrowwidth -1 mul arrowlength arrowinset mul rlineto
closepath
arrowstroke 0 ne {
gsave
arrowstroke setlinewidth stroke
grestore
} if
fill
} def
%
% General arrow. Call as { arrowspec } angle arrow
% arrow is drawn at angle degrees clockwise of down
% arrowspec is code for drawing a downward pointing arrow
/arrow1 {
gsave
rotate
exec
grestore
} def
%
}
%
%============================================================
%============================================================
% Basic line drawing
% #[ fixdash :
%
\special{! /fixdash{
% Usage: r dashsize fixdash
% Sets renormalized dashsize, doing
% [rdsize rdsize] 0 setdash
% so that n+1/2 patterns fit in length r
% If dsize is too big or if dsize is zero, use continuous line
% Uses stack, no named variables.
2 copy gt
1 index 0 ne
and
{
2 copy
2 mul div 0.5 sub round
dup 0 le { pop 0 } if
2 mul 1 add exch pop div
dup 2 array astore 0 setdash
}
{ pop pop [] 0 setdash }
ifelse
} def }
%
% #] fixdash :
% #[ dashline :
%
\special{! /dashline{
% Draws a straight dashed line: x1,y1,x2,y2
% Assumes dsize already set
% The pattern is ideally [dsize dsize] 0 setdash
% but we want to have (2*n+1)/2 patterns, so dsize must be rounded
% If dsize is too large or zero, use a continuous line
% Pure stack operation.
gsave
distance dsize fixdash % Function distance leaves points on stack
newpath
moveto
lineto
stroke
grestore
} def }
% #] dashline :
% #[ dasharc :
%
\special{! /dasharc{
% Draws an arc segment anticlockwise:
% x_center, y_center, radius, start_angle, end_angle
% Assumes angdsize (radians) set elsewhere
gsave
3 copy sub abs
% Top of stack is copy of radius, start_angle, end_angle
pi mul 180 div mul
% Top of stack is arc length
3 index angdsize mul fixdash
newpath arc stroke
grestore
} def }
%
% #] dasharc :
%============================================================
%============================================================
%
% #[ doublegluon :
%
\special{! /doublegluon{
%
% Draw gluon, possibly double
% We have a 'head' and a 'tail' and inbetween the 'body'
% The head + tail is 2 windings. The body is num-1 windings.
%
gsw
/linesep ed
/num ed /ampi ed
normalizeline /dr ed
%
linesep 0 eq
{ 0 0 dr 0 ampi num gluon1 }
{
0 linesep 2 div dup dr exch ampi num gluon1
0 linesep -2 div dup dr exch ampi num gluon1
}
ifelse
grestore
} def }
%
% #] doublegluon :
% #[ gluon1 :
%
\special{! /gluon1{
% Draw a single gluon
% We have a 'head' and a 'tail' and inbetween the 'body'
% The head + tail is 2 windings. The body is num-1 windings.
%
gsave
/num ed /ampi ed
normalizeline /dr ed
%
/num num 0.5 sub round def
/inc dr num 2 mul 2 add div def % increment per half winding
/amp8 ampi 0.9 mul def
amp8 0 lt {/amp8 amp8 neg def} if
%
/x1 inc 2 mul def
%
newpath
0 0 moveto
inc 0.1 mul ampi 0.5 mul inc 0.5 mul ampi inc 1.4 mul ampi curveto
x1 amp8 add dup ampi exch ampi neg dup x1 exch curveto
%
2 1 num {
pop
x1 amp8 sub dup ampi neg exch ampi dup x1 inc add exch curveto
/x1 x1 inc dup add add def
x1 amp8 add dup ampi exch ampi neg dup x1 exch curveto
} for
%
x1 amp8 sub dup ampi neg exch ampi dup x1 inc 0.6 mul add exch curveto
x1 inc 1.5 mul add ampi dr inc 0.1 mul sub ampi 0.5 mul dr 0 curveto
stroke
%
grestore
} def }
%
% #] gluon1 :
% #[ doublephoton :
%
\special{! /doublephoton{
%
% Draws a photon from x1,y1 to x2,y2 with amplitude A and n wiggles
% Possibly double
%
gsw
/linesep ed
/num ed /ampi ed
normalizeline /dr ed
%
linesep 0 eq
{ 0 0 dr 0 ampi num photon1 }
{
0 linesep 2 div dup dr exch ampi num photon1
0 linesep -2 div dup dr exch ampi num photon1
}
ifelse
grestore
} def }
%
% #] doublephoton :
% #[ photon1 :
%
\special{! /photon1{
%
% Draws a single photon from x1,y1 to x2,y2 with amplitude A and n wiggles
%
gsave
/num1 ed /ampi1 ed
normalizeline /dr ed
%
/num1 num1 2 mul 0.5 sub round def
/x2 dr num1 div def
/sign 1 def
1 1 num1 {
pop
newpath
0 0 moveto
4 3 div x2 mul pi div dup neg x2 add
4 3 div ampi1 sign mul mul dup 3 1 roll
x2 0 curveto
stroke
/sign sign neg def
x2 0 translate
} for
%
grestore
} def }
%
% #] photon1 :
% #[ zigzag :
%
\special{! /zigzag{
%
% Draws a zigzag line from x1,y1 to x2,y2 with amplitude A and n zigzags
%
gsw /num ed /ampi ed
normalizeline /dr ed
%
/num num 2 mul 0.5 sub round def
/x2 dr num div def
/sign 1 def
1 1 num {
pop
newpath
0 0 moveto
x2 2 div ampi sign mul lineto
x2 0 lineto
stroke
/sign sign neg def
x2 0 translate
} for
%
grestore
} def }
%
% #] zigzag :
% #[ doublephotonarc :
%
\special{! /doublephotonarc{
%
% Draws a gluon on an arcsegment
% gluon_radius, num, linesep (0 for no-double),
% clock, radius, start_angle, end_angle, x_center, y_center
% in which num is the number of wiggles of the photon.
%
gsw
normalizearc
/darc ed /radius ed /linesep ed /num ed /ampli ed
%
/num num 2 mul round def % number of half wiggles
/darc1 darc num div def
/cp darc1 cos def
/sp darc1 sin def
darc1 2 div dup
/cp2 exch cos def
/sp2 exch sin def
%
linesep 0 eq
{
radius photonarc1
}
{
linesep 2 div radius add photonarc1
linesep -2 div radius add photonarc1
}
ifelse
%
grestore
} def }
%
% #] doublephotonarc :
% #[ photonarc1 :
%
\special{! /photonarc1{
% Usage: radius photonarc1
% Draws a single photon on an arcsegment.
% Called from doublephotonarc with coordinates centered on center,
% start on x-axis.
% Assume the following are set: num, ampli, arcend phi, arcstart phi/2, cp,
% cp2, sp, sp2.
% Draws a photonarc center at x1,y1, radius arcstart,arcend, amplitude
% number of wiggles, width, scale
%
gsave
/radius1 ed
% Local copy of amplitude, since I change it
/ampli1 ampli def
%
newpath
1 1 num {
pop
radius1 0 moveto
/beta radius1 darc1 mul 180 ampli1 mul div def
/tt sp cp beta mul sub cp sp beta mul add div def
/amp1 radius1 ampli1 add 8 mul beta cp2 mul sp2 sub mul beta 4 cp add mul
tt cp mul 3 mul sp 4 mul sub add radius1 mul sub
beta tt sub 3 mul div def % this is x2
radius1 ampli1 add 8 mul cp2 mul 1 cp add radius1 mul sub 3 div amp1 sub
dup radius1 sub beta mul % x1,y1
amp1 dup radius1 cp mul sub tt mul radius1 sp mul add % x2,y2
radius1 cp mul radius1 sp mul % x3 y3
curveto
/ampli1 ampli1 neg def
darc1 rotate
} for
stroke
%
grestore
} def }
%
% #] photonarc :
% #[ doublegluearc :
%
\special{! /doublegluearc{
%
% Draws a gluon on an arcsegment
% gluon_radius, num, linesep (0 for no-double),
% clock, radius, start_angle, end_angle, x_center, y_center
% in which num is the number of windings of the gluon.
%
gsw
normalizearc
/darc ed /radius ed /linesep ed /num ed /ampi ed
/num num 0.5 sub round def
%
linesep 0 eq
{ radius gluearc1 }
{
linesep 2 div radius add gluearc1
linesep -2 div radius add gluearc1
}
ifelse
%
grestore
} def }
%
% #] doublegluearc :
% #[ gluearc1 :
\special{! /gluearc1{
% Usage: radius gluearc1
% Draws a single gluon on an arcsegment.
% Called from doublegluearc with coordinates centered on center,
% start on x-axis.
% Assume: num, ampi and darc set.
% Method:
% 1: compute length of arc.
% 2: generate gluon in x and y as if the arc is a straight line
% 3: x' = (radius+y)*cos(x*const)
% y' = (radius+y)*sin(x*const)
%
gsave
/radius1 ed
/dr radius1 darc mul pi mul 180 div def % length of segment.
/const darc dr div def % conversion constant
darc 360 lt
{
/inc dr num 2 mul 2 add div def % increment per half winding
}
{ % Full loop, so don't have extra bits on end
/inc dr num 2 mul div def % increment per half winding
}
ifelse
%
/amp8 ampi 0.9 mul def
/amp1 radius1 ampi add def
/amp2 radius1 ampi sub def
/amp3 radius1 ampi 2 div add def
/amp4 amp1 inc amp8 add const mul cos div def
/amp5 amp2 amp8 const mul cos div def
/amp6 amp1 inc 0.6 mul amp8 add const mul cos div def
/amp7 amp1 inc 0.9 mul const mul cos div def
amp8 0 lt {/amp8 amp8 neg def} if
%
%
newpath
darc 360 lt
{
/x1 inc 2 mul def
radius1 0 moveto
% Normal arc has special head segment
inc 0.1 mul const mul dup cos amp3 mul exch sin amp3 mul
inc 0.5 mul const mul dup cos amp7 mul exch sin amp7 mul
inc 1.4 mul const mul dup cos amp1 mul exch sin amp1 mul
curveto
x1 amp8 add const mul dup cos amp6 mul exch sin amp6 mul
x1 amp8 add const mul dup cos amp5 mul exch sin amp5 mul
x1 const mul dup cos amp2 mul exch sin amp2 mul
curveto
% Range of main segments
2 1 num
}
{
/x1 0 def
amp2 0 moveto
1 1 num
}
ifelse
{
pop
x1 amp8 sub const mul dup cos amp5 mul exch sin amp5 mul
x1 amp8 sub const mul dup cos amp4 mul exch sin amp4 mul
x1 inc add const mul dup cos amp1 mul exch sin amp1 mul
curveto
/x1 x1 inc dup add add def
x1 amp8 add const mul dup cos amp4 mul exch sin amp4 mul
x1 amp8 add const mul dup cos amp5 mul exch sin amp5 mul
x1 const mul dup cos amp2 mul exch sin amp2 mul
curveto
} for
%
darc 360 lt
{
x1 amp8 sub const mul dup cos amp5 mul exch sin amp5 mul
x1 amp8 sub const mul dup cos amp6 mul exch sin amp6 mul
x1 inc 0.6 mul add const mul dup cos amp1 mul exch sin amp1 mul
curveto
x1 inc 1.5 mul add const mul dup cos amp7 mul exch sin amp7 mul
dr inc 0.1 mul sub const mul dup cos amp3 mul exch sin amp3 mul
dr const mul dup cos radius1 mul exch sin radius1 mul
curveto
}
if
stroke
%
grestore
} def }
%
% #] gluearc1 :
% #[ dasharrowdoubleline :
%
\special{! /dasharrowdoubleline{
%
% arrowspec, arrowpos, flip, linesep, dsize,
% x1, y1, x2, y2, width, scale
% If linesep == 0, then single line, else double with separation linesep.
% Draws a dashed double straight line with arrow.
% If dsize==0, then continuous line.
% If linesep==0, then single line.
gsw
normalizeline
/dr ed
/dsize ed
/linesep ed
/flip ed
garrow
%
% If linesep is negative, that means the arrow is flipped.
% But the lineend coordinates are already flipped, so there is
% no need to make any adjustment; i.e., replace linesep by
% absolute value.
/linesep setabs
/linewidth width def
%
/y11 linesep 0.5 mul def
/y22 linesep -0.5 mul def
0 y11 dr arrowpos mul y11 dashline
linesep 0 ne
{ 0 y22 dr arrowpos mul y22 dashline }
if
dr arrowpos mul 0 translate
/arrowspec load
flip { -90 }{ 90 } ifelse
arrow1
0 y11 dr 1 arrowpos sub mul y11 dashline
linesep 0 ne
{ 0 y22 dr 1 arrowpos sub mul y22 dashline }
if
grestore
} def }
%
% #] dasharrowdoubleline :
% #[ arc2 :
%
\special{! /arc2{
% Draws an arc segment:
% arrowspec, arrowpos, flip, linesep, dsize,
% clock, radius, start_angle, end_angle, x_center, y_center, width, scale
% If linesep == 0, then single line, else double with separation linesep.
%
gsw
normalizearc
/darc ed /radius ed
/dsize ed /linesep ed
/angdsize dsize radius div def
/flip ed
garrow
/arcmid
darc arrowpos mul
def
dsize 0 eq
{ linesep 0 eq
{ 0 0 radius 0 darc dasharc }
{ 0 0 radius linesep 2 div add 0 darc dasharc
0 0 radius linesep -2 div add 0 darc dasharc
}
ifelse
}
{ linesep 0 eq
{ 0 0 radius 0 arcmid dasharc
0 0 radius arcmid darc dasharc
}
{
0 0 radius linesep 2 div add 0 arcmid dasharc
0 0 radius linesep -2 div add 0 arcmid dasharc
0 0 radius linesep 2 div add arcmid darc dasharc
0 0 radius linesep -2 div add arcmid darc dasharc
}
ifelse
}
ifelse
arcmid rotate
radius 0 translate
/arrowspec load flip { 0 } { 180 } ifelse arrow1
grestore
} def }
%
% #] arc2 :
% #[ vertex :
%
\special{! /vertex{
%
% Puts a fat dot at x,y size is the radius of the dot
%
gs
/dotsize ed
translate
newpath
0 0 dotsize 0 360 arc
fill stroke
grestore
} def }
%
% #] vertex :
% #[ bcirc :
%
\special{! /bcirc{
%
% Draws an anti-clockwise blanked circle:
% x_center, y_center, radius
%
gsw /radius ed
%
translate % x and y are still on stack
%
gsave
1 setgray
newpath 0 0 radius 0 360 arc fill
grestore
newpath 0 0 radius 0 360 arc stroke
grestore
} def }
%
% #] bcirc :
% #[ gcirc :
%
\special{! /gcirc{
%
% Draws an anti-clockwise blanked gray circle:
% x_center, y_center, radius, grayscale
%
gsw /gcolor ed /radius ed
%
translate % x and y are still on stack
%
1 setgray
newpath 0 0 radius 0 360 arc fill
gcolor setgray
newpath 0 0 radius 0 360 arc fill
0 setgray
newpath 0 0 radius 0 360 arc stroke
grestore
} def }
%
% #] gcirc :
% #[ ccirc1 :
%
\special{! /ccirc1{
%
% Draws an anti-clockwise circle :
% x_center, y_center, radius
% Part 1: the contents in background color
%
gsw /radius ed
%
translate % x and y are still on stack
%
newpath 0 0 radius 0 360 arc fill
grestore
} def }
%
% #] ccirc1 :
% #[ ccirc2 :
%
\special{! /ccirc2{
%
% Draws an anti-clockwise circle :
% x_center, y_center, radius
% Part 1: the contents in background color
%
gsw /radius ed
%
translate % x and y are still on stack
%
newpath 0 0 radius 0 360 arc stroke
grestore
} def }
%
% #] ccirc2 :
% #[ box :
%
\special{! /box{
%
% Draws a box x1,y1,x2,y2
%
gsw p2 p1
abox stroke
grestore
} def }
%
% #] box :
% #[ bbox :
%
\special{! /bbox{
%
% Draws a blanked out box x1,y1,x2,y2
%
gsw p2 p1
gsave
1 setgray abox fill
grestore
abox stroke
grestore
} def }
%
% #] bbox :
% #[ gbox :
%
\special{! /gbox{
%
% Draws a blanked out gray box x1,y1,x2,y2,color
%
gsw /gcolor ed p2 p1
1 setgray abox fill
gcolor setgray abox fill
0 setgray abox stroke
grestore
} def }
%
% #] gbox :
% #[ cbox1 :
%
\special{! /cbox1{
%
% Draws a blanked out colored box x1,y1,x2,y2
% Part 1: the background
%
gsw p2 p1
abox fill
grestore
} def }
%
% #] cbox1 :
% #[ cbox2 :
%
\special{! /cbox2{
%
% Draws a blanked out colored box x1,y1,x2,y2
% Part 1: the box
%
gsw p2 p1
abox stroke
grestore
} def }
%
% #] cbox2 :
% #[ triangle :
%
\special{! /triangle{
%
% Draws a triangle x1,y1,x2,y2,x3,y3
%
gsw p3 p2 p1
atriangle stroke
grestore
} def }
%
% #] triangle :
% #[ btriangle :
%
\special{! /btriangle{
%
% Draws a blanked out triangle x1,y1,x2,y2,x3,y3
%
gsw p3 p2 p1
gsave
1 setgray atriangle fill
grestore
atriangle stroke
grestore
} def }
%
% #] btriangle :
% #[ gtriangle :
%
\special{! /gtriangle{
%
% Draws a blanked out gray triangle x1,y1,x2,y2,x3,y3,color
%
gsw /gcolor ed p3 p2 p1
1 setgray atriangle fill
gcolor setgray atriangle fill
0 setgray atriangle stroke
grestore
} def }
%
% #] gtriangle :
% #[ ctriangle1 :
%
\special{! /ctriangle1{
%
% Draws a blanked out colored triangle x1,y1,x2,y2,x3,y3
% Part 1: the background
%
gsw p3 p2 p1
atriangle fill
grestore
} def }
%
% #] ctriangle1 :
% #[ ctriangle2 :
%
\special{! /ctriangle2{
%
% Draws a blanked out colored triangle x1,y1,x2,y2,x3,y3
% Part 1: the triangle
%
gsw p3 p2 p1
atriangle stroke
grestore
} def }
%
% #] ctriangle2 :
% #[ btext :
%
\special{! /btext{
%
% Makes a box that has the text centered in it
% The center of the box is at x,y and the box is just large enough
% for the text.
% x,y,text,fontsize,linewidth,scale
%
gsw /fsize ed /thetext ed translate
/hsize thetext stringwidth pop def
/x1 hsize fsize add 2 div neg def
/y1 fsize 2 mul 3 div neg def
/x2 x1 neg def /y2 y1 neg def