File: dpic.1.src

package info (click to toggle)
dpic 2023.06.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,868 kB
  • sloc: ansic: 10,262; yacc: 5,827; makefile: 286; sh: 156; awk: 129; sed: 32
file content (1371 lines) | stat: -rw-r--r-- 30,987 bytes parent folder | download
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
.\" This is the man-page source for dpic on Unix or Linux systems.
.\"
.\" BSD Licence:
.\" 
.\" Copyright (c) 2023, J. D. Aplevich
.\" All rights reserved.
.\" 
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 
.\" * Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 
.\" * Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" Use \(ts instead of ".
.tr \(ts"
.\"
.TH DPIC 1 "2017 Aug 01"
.SH NAME
dpic \(hy convert pic\(hylanguage input to LaTeX\(hycompatible and other formats
.SH SYNOPSIS
.B "dpic [ \-defghmprstvx ] [ -z ] ["
.I infile
.B "] [>"
.I outfile
.B "]"
.P
Typically,
.I infile
is of the form
.I name
.B "[.pic]"
and
.I outfile
is of
.br
the form
.I name
.B ".[tex|eps|pdf|fig|mp|svg]"
.SH "OPTIONS"
.B (none)
LaTeX picture-environment output (very limited font\(hybased drawing commands)
.br
.B \-d
PDF output, basic strings
.br
.B \-e
pict2e output
.br
.B \-f
Postscript output, strings in psfrag format
.br
.B \-g
TikZ\(hypgf output
.br
.B \-h
write help message and quit
.br
.B \-m
mfpic output (see mfpic documentation)
.br
.B \-p
PSTricks output
.br
.B \-r
raw Postscript output, no automatic string formatting
.br
.B \-s
MetaPost output
.br
.B \-t
eepicemu output (slightly less limited than LaTeX picture output)
.br
.B \-v
svg output
.br
.B \-x
xfig 3.2 output
.br
.B \-z
safe mode (access to external files disabled)
.\"
.SH DESCRIPTION
Dpic accepts a tight subset of the pic drawing language accepted by
GNU pic (sometimes named gpic) or AT&T pic, and emits lower\(hylevel
drawing commands for insertion into LaTeX documents, for processing by
the xfig or Inkscape drawing tools, or for direct display as encapsulated
Postscript, PDF, or SVG. LaTeX-compatible output can contain arbitrary
text for formatting.  Commands to be passed through to the postprocessor
(PSTricks, Tikz\(hypgf, etc.)  can be included.  Dpic returns EXIT_SUCCESS
(normally 0) if messages no more severe than warnings were generated,
otherwise EXIT_FAILURE (normally 1).

A few pic-language extensions unique to dpic
are implemented for specific purposes.

.SH "LANGUAGE SUMMARY"
Input consists of a sequence of ASCII text lines.
The characters
.B LF
(\\n) and
.B CR
(\\r) have identical effect,
and
.B ETX
(\\003) is reserved for internal use.
Characters outside the range of 0 to 127 are allowed in strings but
receive no special treatment.

The first line of a picture is
.B ".PS"
and the last is
.B ".PE,"
with lines between
these two converted into low\(hylevel drawing commands for the postprocessor
chosen by the option.
Lines outside of
.B ".PS ... .PE"
pass through dpic unchanged.
.SS Coordinates
Coordinate axes in the pic
language point to the right and up.
The drawing units are inches by default but the statement
.P
.B "  scale = 25.4"
.P
at the beginning of the diagram has the effect of changing
the units to millimetres.
.\"
.SS Drawn objects
The primitive drawn objects consist of the planar objects
.B "box, circle, ellipse;"
the linear objects
.B "line, arrow, move, spline;"
and
.B "arc,"
which has characteristics of both planar and linear objects.
A
.I block
is a pair of square brackets enclosing other objects:
.B [
.I anything
.B ]
and is a planar object.
The complete diagram is contained implicitly in a block.
.P
A
.I string
is a planar object similar to a box,
but the
pic
language also allows strings to be attached to other objects as overlays,
in which case they are part of the object.
.P
The current drawing position
.B Here
is always defined. 
Initially and at the beginning of a block,
.B Here
is 0,0.
Similarly, the current direction, which can be any of
.B "up, down, left, right,"
is set as
.B right
initially.
.P
Each drawn object has an entry point and exit point that depend
on the current direction.
The entry point is placed by default at the current position. 
Objects can also be placed explicitly with respect to absolute
coordinates or relative to other objects.
The exit point becomes the new current position.
.SS Labels
A
.I label
in
pic
is an alphameric sequence that starts with an uppercase letter.
Dpic allows variables and labels to be subscripted; thus
.B T
and
.B T[5]
are distinct labels.
The value in brackets can be any expression, comma-separated
expression pair, or a defined position,
but expressions are rounded to the nearest integer value.
A label gives a symbolic name to a position or drawn object;
for example,
.P
.B "   Post: Here + (1,2)"
.br
.B "   Bus[23]: line right 4"
.SS Defined points
Once drawn, a linear object has defined points
.B ".start, .center,"
and
.B ".end,"
which can be referenced as known positions, for example,
.P
.B "   L: line; line up 0.5 from L.c"
.P
where
.B .center
has been abbreviated as
.B .c
.P
The defined points for a planar object are the compass points
on its periphery given by
.B ".n, .s, .e, .w, .nw, .ne, .se, .sw,"
together with
.B ".center, .top, .bottom, .right, .left." 
For an arc, these points correspond to the circle of which the arc is a
part, with the addition of
.B .start
and
.B .end.
.P
A
.I block
has defined points similar to a box, but can also have others in its
interior.
For the example
.P
.B "   A: [ circle; Q: [ line; circle ]; T: Q.n ]"
.P
the defined points are as follows:
.P
   The points of the outer block as if it were a box, for
.\" .br
   example,
.B A.ne
.P
   A position defined in the block, for example,
.B A.T
.P
   The defined points of labeled objects inside the block,
.\" .br
   preceded by a dot, for example,
.B A.Q
(the centre of
.\" .br
   block
.B Q),
or
.B A.Q.ne
(the northeast point of
.B Q).
.P
   The defined points of enumerated objects inside the
.\" .br
   block, preceded by a dot (but make sure there is a space
.\" .br
   after the dot if it is followed by a number rather than
.\" .br
   an expression in braces), for example,
.B "A.Q. 1st circle.n"
.\" .br
   or (better)
.B "A.Q.{1}st circle.n"
.SS Language elements
The lines defining a picture are separated by newline characters
or semicolons.
Newlines are significant except after
.B "then, ;, :, {, else,"
or newline.
.P
A line is continued to the next if the rightmost character is a backslash.
.P
Non-continuation lines beginning with a period are ignored, except for
.B .PS
and
.B .PE
lines.
.P
The
pic
source may be commented by placing each comment to the right of a
.B #
character (unless the
.B #
is in a string).
.P
The language elements include the following:
.P
   A drawing command with optional label, for example,
.\" .br
.B box
or
.B "A: box"
.P
   A position\(hylabel definition, for example
.B A:
.I position
.P
   An assignment to a variable, for example
.B x = 5
.P
   A
.I direction
(to change the default), for example,
.B up
.P
Branching is performed by
.P
.B "   if"
.I expr
.B "then {"
.I dotrue
.B "} else {"
.I dofalse
.B }.
.P
The looping facility is
.P
.B "   for"
.I variable
.B =
.I expr
.B to
.I expr
.B "[by [*]"
.I incr
.B "] do {"
.I anything
.B "}."
.P
The loop variable is incremented by 1 by default, otherwise by
.I incr
(which may be a negative expression)
unless it is preceded by the asterisk, in which case the loop variable
is multiplied by
.I incr.
The loop variable may be changed by statements in the loop, thereby
controlling the number of loop repetitions.
.P
Braces occur in several contexts.
When used independently of other language elements, as
.P
.B "   {"
.I anything
.B "}"
.P
the left brace
saves the current position and direction, and the right brace restores
them to the saved values after the enclosed lines have been processed.
.P
Arbitrary postprocessor commands can be generated using
.P
.B "   command"
.I string,
.P
which inserts the contents of
.I string
into the output.
The
.I string
contents must be compatible with the chosen postprocessor.
Similarly, any line that begins with a backslash is copied literally
to the output.
.P
The line
.P
.B "   exec"
.I string
.P
executes the contents of
.I string
as if it were a normal input line.
.P
To execute operating-system shell commands, use
.P
.B "   sh"
.I string
.P
and to read lines from an external file, use
.P
.B "   copy"
.I string
.P
These commands are disabled by the
dpic
option
.B \-z
or by a compile\(hytime switch.
.P
The command
.P
.B "   print"
.I "expr|position|string"
.B "[ >"
.I string
.B "| >>"
.I string
.B ]
.P
prints or appends its argument to the file named in the string
on the right, or by default to the standard error.
Printing to a file is disabled by the \-z option.
.P
.SS Macros
The
pic
language includes macro definition and expansion, using either
.P
.B "   define"
.I name
.B "{"
.I anything
.B "},"
.P
or
.P
.B "   define"
.I name
.B "X"
.I anything
.B "X,"
.P
where X is any character except {. When
.I name
appears alone or with arguments in parentheses as
.I "name(arg, ...)"
then it is replaced by the contents between the delimiters in the macro
definition.
Arguments are separated by commas except that
a comma in an argument is ignored within a string, parentheses, or brackets.
In this substitution, occurrences of
.B $1
are replaced literally by the first argument (not by its value, if any),
and so on for other arguments.
.P
The value
.B $+
in a macro is the number of arguments given to the macro.
dpic
ignores white space (spaces, new lines, and tab characters) that directly
precede an argument in a macro invocation.
A macro definition can be deleted by
.P
.B "   undefine"
.I name
.P
Macro definitions are global, which may require judicious
undefinition of macros if there is a risk of name clashes.
.\" .SS Object sizes
.\" Objects are drawn by specifying their size parameters
.\" .B "height, width, radius, diameter,"
.\" or truncated as
.\" .B "ht, wid, rad, diam,"
.\" respectively, as needed; for example,
.\" .P
.\" .B "   A: box [height"
.\" .I expr]
.\" .B [width
.\" .I expr]
.\" .P
.\" but a default value is used if any parameter is omitted.
.\" Thereafter, the size parameters of the object can be used
.\" in expressions, for example
.\" .P
.\" .B "   circle diam A.ht"
.SS Drawing commands
An object is drawn using the following general format:
.P
.I "   "
.B "["
.I Label
.B ":]"
.I object
.B "["
.I attributes
.B "] ["
.I placement
.B "] ["
.I strings
.B "]"
.P
The items following
.I object
can occur in any order, but the order can make a difference to the
drawn result, since lines are read and interpreted from left to right.
Defaults are assumed for all drawing parameters as necessary.
For example, the sequence
.P
.B "   circle" \(tsChew\(ts; arrow; box \(tsSwallow\(ts
.br
.B "   line; arc cw ->; ellipse \(tsDigest\(ts"
.P
draws a simple flow diagram using default sizes for all objects,
with centered words in the circle, box, and ellipse. 
.\"
.SS Attributes
An
.I attribute
is a keyword or keywords followed by expressions as appropriate.
Attributes are used to set parameters that control the placement,
size, and appearance of objects.
.P
The dimension attributes are
the following, showing valid abbreviations:
.P
.B "   height|ht|width|wid|radius|rad|diameter|diam|scaled"
.I expr
.P
When appended to linear objects,
.B height
and
.B width
apply to arrowhead dimensions.
The
.B scaled
attribute scales the object by
.I expr.
.P
The postprocessed size of a string is unknown in advance to the
pic
processor, but once known, the bounding box dimensions can be specified
explicitly as for other drawn objects, as shown:
.P
.I "   string"
.B wid
.I expr
.B ht
.I expr
.P
The thickness of lines defining an object are modified using
the environment variable
.B linethick
or the attribute
.P
.B "   thickness|thick"
.I expr
.P
expressed in points.
Line thickness is independent of any scaling.
.P
Solid lines are drawn by default; this can be modified with
.P
.B "   solid|invisible|invis"
.P
or with
.P
.B "   dotted|dashed ["
.I expr
.B "]"
.P
the optional expression in the latter setting the length and distance
between dashes or dots.
.P
The following attributes are for putting arrowheads at the start, end,
or both ends of a linear object:
.P
.B "   <\-|\->|<\-> ["
.I expr
.B "]"
.P
The default for
.B arrow
objects is
.B "\->."
The shape parameter
.I expr
may be omitted, in which case the value of the environment variable
.B arrowhead
is used.
The accepted values of expr are currently 0, 1, and 3, with 1 the default.
.P
The drawing direction of an arc is changed by the attribute
.P
.B "   ccw|cw"
.P
with
.B ccw
the default.
.P
To fill an object with a shade of gray, use the attribute
.P
.B "   fill ["
.I expr
.B "]"
.P
where the value of
.I expr
can vary from 1, meaning white, to 0, meaning black.
A linear object defining a path can be filled where the postprocessor allows,
currently for MFpic, MPost, PDF, PGF, PS, PSfrag, PSTricks, and SVG output.
.P
Line color can be set using
.P
.B "   outline|outlined"
.I string
.P
The pic language knows no details about color; the string contents must be
compatible with the postprocessor.
For example,
the predefined colours of LaTeX or Tikz\(hypdf packages can be specified,
or custom colors can be defined using the
.P
.B "   command"
.I string
.P
facility so that the postprocessor will know about them.
.P
Filling by color is similar, using the attribute
.P
.B "   shaded"
.I string
.P
and, when the object is planar and both the fill and outline colors
are the same, the two attributes can be combined as
.P
.B "   colour|color|colored|coloured"
.I string
.P
in which all four spellings are equivalent.
.P
Finally, the attribute
.P
.B "   same"
.P
duplicates the properties of the previously drawn object of the same type,
but with the current default placement.
.P
In addition to scale changes effected by the
.B scale
variable, the size of the complete picture can be set
by appending one or two terms to the
.B .PS
line as shown:
.P
.B "   .PS"
[x [y]]
.P
where x and y evaluate to constant values.
On encountering the 
.B ".PE"
line, the picture width w and height h are calculated.
If x > 0 then the picture is scaled so that w = x.
If h > y > 0 or if x = 0 and y > 0 then the picture is scaled
so that h = y.
Horizontal and vertical scaling are not independent.
Text size, line thickness, and arrowheads are not scaled.
The units are inches, so for example,
.P
.B "   .PS 100/25.4"
.P
sets the final picture width to 100 mm.
Printed string text may extend beyond the rectangular boundaries
defined by w and h unless the text dimensions have been explicitly set.
.P
If the final diagram width exceeds the environment variable
.B maxpswid
or the height exceeds
.B maxpsht,
both of which can be changed by assignment,
then the diagram is scaled as for x and y above.
.\" 
.SS Placement of drawn objects
An object is placed by default so that its entry is at
the current point.
.P
Explicit placement is obtained with
.P
.I "   object"
.B at
.I position
.P
which centers the object at
.I position,
or
.P
.I "   object"
.B with
.I defined point
.B at
.I position
.P
for example,
.P
.B "   arc cw from"
.I position
.B to
.I position
.B "with .c at"
.I position
.P
A block can also be positioned by reference to a displacement from its
lower left corner, for example,
.P
.B "   A: [" 
.I contents
.B "] with (0.5,0.2) at"
.I position.
.P
Linear objects are placed by default with the
.B .start
point placed at the current drawing
position; otherwise linear objects are defined using a
.I linespec,
which is of the form
.P
.I "linespec"
.B "= from"
.I position
.B "| to"
.I position
.B "|"
.I direction
.B "["
.I expr
.B "]"
.br
.B "          |"
.I "linespec linespec"
.br
.B "          |"
.I "linespec"
.B then
.I linespec
.P
where
the second line means that
.I linespecs
can be concatenated, and the third
that multisegment linear objects are drawn using multiple
.I linespecs
separated by
.B then.
.P
As an example, the following draws a triangle with the leftmost vertex
at the current point:
.P
.B "   line up 2 right 1.5 then down 3 then to Here"
.P
Exceptionally, the
.I linespec
.P
.B "   to"
.I position
.B to
.I position
.B "to ..."
.P
is multiple and does not require the
.B then
keyword, but this also means that the
.I linespec
.P
.B "   up"
.I expression
.B to
.I position
.P
is multiple and creates a two-segment line.
.P
A single
.I expr
is also an acceptable
.I linespec
immediately after a linear object and means that the
.I object
is drawn to length
.I expr
in the current direction.
The exception to this is
.P
.B "   spline"
.B "["
.I expr
.B "]"
.I linespec
.P
for which the
.I expr
is a spline tension parameter.
If
.I expr
is omitted, a straight line is drawn to the midpoint of the first two
spline control points and from the midpoint of the last two to the last
point; the spline is tangent to all midpoints between control points.
If
.I expr
is present, the spline is tangent at the first and last control points
and at all other midpoints, and the spline tension can be
adjusted.
Tension values between 0 and 1 are typical.
.P
In cases where all of the points of a multisegment linear object are
not known in advance or inconvenient to calculate, the drawing command
.P
.B "   continue"
.I linespec
.P
will append a segment to the previously drawn linear object as if
.B continue
were
.B then,
with two differences.
Arbitrary calculations may be done between the previous object and the
.B continue
statement, and the current point is the exit point of the previous object.
.P
The construction
.P
.B "   line from"
.I position
.B to
.I position
.B chop
.B "["
.I expr
.B "]"
.P
truncates the line at each end by the value of
.I expr
or, if
.I expr
is omitted, by the current value of environment variable
.B circlerad

Otherwise
.P
.B "   line from"
.I position
.B to
.I position
.B chop
.I expr1
.B chop
.I expr2
.P
truncates the line by the two specified distances at the ends.
Truncation values can be negative.
.P
The attribute
.P
.B "   by"
.I position
.P
is for positioning, for example,
.P
.B "   move by (5,6)"
.SS Variables and expressions
Variable names are alphameric sequences beginning with a lower\(hycase
letter, optionally subscripted as for labels, and are defined by
assignment.
For example, the following line defines the variable
.B x
if it does not already exist in the current scope:
.P
.B "   x ="
.I expr
.P
The scope of
pic
variables is the current block in which they are defined, including blocks
defined later within the current block.
The assignment
.P
.B "   x :="
.I expr
.P
or any assignment using an operator in the set
.P
.B "   := += -= *= /= %="
.P
requires
.B x
to have been defined previously in the current block or an enclosing block.
.P
Expressions consist of floating\(hypoint values combined using the unary
operator "!" for logical negation and the usual parentheses and binary
operators in decreasing order of precedence:
.P
.B "   ^"
.br
.B "   * / %"
.br
.B "   + \-"
.br
.B "   == != >= <= < >"
.br
.B "   &&"
.br
.B "   ||"
.P
In logical tests, the value 0 is equivalent to false and a nonzero value
to true, with resulting true value of 1.
.P
A floating\(hypoint value is obtained as
an integer, a number with
.B e
syntax, a function value, a size value of a drawn object, for example,
.P
.B "   last box.ht,"
.P
or the horizontal or vertical coordinate of a
.B position,
obtained respectively as
.P
.I "   position"
.B .x|.y
.P
The single\(hyargument functions are
.B "abs, acos, asin, cos, exp, expe, int, log, loge,"
.B "sign, sin, sqrt, tan, floor."
The functions
.B exp
and
.B log
are base 10.
The function
.B rand()
delivers a random number between 0 and 1, and
.B rand
.I (expr)
initializes the random number generator.
.P
The two\(hyargument functions are
.B "atan2, max, min, pmod"
where
.B pmod
is the modulo function delivering a positive value.
.\" .SS Scope of variables
.SS Predefined variables
The following variables are predefined on invocation of dpic:
.B optTeX, opttTeX, optPict2e, optPSTricks, optPDF, optPGF,
.B optMFpic, optPS, optPSfrag,
.br
.B optMpost,
and
.B optSVG.
Variable
.B dpicopt
is set according to the output option chosen, so that if one of options
.B \-p
or
.B \-g
has been invoked for example, then the test
.P
.B "   if dpicopt == optPSTricks || dpicopt == optPGF then { ... }"
.P
will selectively execute its body statements.
In addition, variable
.B optsafe
has value
.B true
if the
.B \-z
option has been selected or dpic has been compiled in safe mode.
.P
If the specified option is one of
.B \-v
(SVG),
.B \-d
(PDF), or
.B \-r
(raw postscript), then
the variable
.B dptextratio
is defined, with default value 0.66, together with the variable
.B dpPPI
with default value 0.96.  The latter is the assumed pixel density per inch
and the former is the ratio of text height to nominal point size.
These variables are used by the output routines and can be
changed by assignment.
.P
If the
.B \-x
(xfig) option has been specified,
then the following two variables are predefined:
.B xfigres
(default value 1200), and
.B xdispres
(default 80).
.SS Predefined environment variables
A set of environment variables establishes the default values of drawing
parameters within the scope of the current block.
Their values are inherited from the superior block, but can be changed
by assignment.
They can be used in expressions like other variables.
The variables, their default values, and default uses are given below
.P
.B "   arcrad       0.25"
   arc radius
.br
.B "   arrowht      0.1 "
    length of arrowhead
.br
.B "   arrowwid     0.05"
   width of arrowhead
.br
.B "   boxht        0.5 "
    box height
.br
.B "   boxrad       0   "
       radius of rounded box corners
.br
.B "   boxwid       0.75"
   box width
.br
.B "   circlerad    0.25"
circle radius
.br
.B "   dashwid      0.05"
dash length for dashed lines
.br
.B "   ellipseht    0.5 "
ellipse height
.br
.B "   ellipsewid   0.75"
ellipse width
.br
.B "   lineht       0.5 "
height of vertical lines
.br
.B "   linewid      0.5 "
length of horizontal lines
.br
.B "   moveht       0.5 "
length of vertical moves
.br
.B "   movewid      0.5 "
length of horizontal moves
.br
.B "   textht       0   "
assumed height of text (11pt for postscript, PDF, and SVG)
.br
.B "   textoffset   2.5/72"
text justification gap
.br
.B "   textwid      0   "
assumed width of text
.P
When a value is assigned to the environment variable
.B scale,
all of the above values are multiplied by the new value of
.B scale.
This is normally done once at the top of the outermost scope of a diagram.
Drawing units are thereby changed but the default physical sizes of
drawn objects remain unchanged since dimensions are divided by the outermost
.B scale
value on output.
The following are unaffected by
.B scale
changes:
.P
.B "   arrowhead    1   "
arrowhead shape
.br
.B "   fillval      0.5 "
fill density
.br
.B "   linethick    0.8 "
line thickness in points
.br
.B "   maxpsht      11.5"
maximum allowed diagram height
.br
.B "   maxpswid     8.5 "
maximum allowed diagram width
.P
The variables
.B maxpswid
and
.B maxpsht
may have to be redefined for large diagrams or
landscape figures, for example.
.SS Positions
A
.I position
is equivalent to a coordinate pair defined in current drawing units,
and can be expressed in the following forms:
.P
.B "   Here"
.\" .br
   The current drawing position.
.P
.I "    expr,expr"
.\" .br
   A pair of expressions separated by a comma.
.P
.B "   ("
.I position
.B ")"
.\" .br
   A position in parentheses for grouping.
.P
.B "   ("
.I position
.B ","
.I position
.B ")"
.\" .br
   Takes the horizontal value from the first position and
.\" .br
   the vertical value from the second.
.P
.I "    position"
.B "+|\-"
.I position
.\" .br
   Vector addition.
.P
.I "    position"
.B "*|/"
.I expr
.\" .br
   Scalar postmultiplication.
.P
.I "    Label"
.\" .br
   The label of a defined position or object.
The position
.\" .br
   is the center of the object.
.P
.I "    expr" 
.B "[of the way] between"
.I position
.B and
.I position
.P
   The example
.B "x between A and B"
is equal to
.B "A*(1\-x) + B*x."
   Any value of
.I expr
is allowed.
.P
.I "    expr"
.B <
.I position, position
.B >
.\" .br
   An abbreviated equivalent of the previous form.
.P
.I "    number"
.B "st|rd|nd|th [last]"
.I object
.\" .br
   An object within the current block, enumerated in order of definition.
.P
   The
.I object
is one of
.P
.B "   line, move, arrow, arc, box, ellipse, circle, spline, [], \(ts\(ts" .
.P
The number can be replaced by
.B "{"
.I expr
.B "}."
For example,
.B last \(ts\(ts
means the last string, and
.B "{2^2}nd []"
means the fourth block in the current scope.
The position is the center of the object.
.P
Parentheses may be required when composite positions or expressions
are used in the above forms.
.P
Finally, a position can be given as
.P
.I "   object"
.B .
.I defined point
.SS Strings
A
.I string
is a sequence of characters enclosed in double quotes.
To include a double quote in a string, precede it with a backslash. Strings
can be concatenated using the
.B "+"
operator.
The C\(hylike function
.P
.B "   sprintf("
.I "format string, expr, ..."
.B ")"
.P
is equivalent to a string.
(Its implementation passes arguments singly to the C snprintf function.)
Expressions are floating\(hypoint values, so the only applicable number
formats are
.B "e, f,"
and
.B "g." 
.P
Multiple strings such as
.I \(tstext1\(ts \(tstext2\(ts
are stacked and centered vertically.
.P
A string attached to an object overlays the object at the center, and
any
.B height
or
.B width
attributes apply to the object, not the string.
However, the justification attributes
.B ljust
and
.B rjust
can be applied to the individual strings of a stack overlaying
an object.
.P
An independent string is placed with its center at the current point
by default, or by specifying the position of one of its defined points
as for any
.I object,
for example,
.P
.B "   "
.B "   \(tsAnimal crackers\(ts wid 82.3/72 ht 9.7/72 with .sw at Q"
.P
The placement qualifiers
.B "above, below, ljust, rjust"
place the string above, below, or justified with respect to the
placement point.
For example,
.P
.B "   \(tsAnimal crackers\(ts at Q ljust above"
.P
places the string above and
.B textoffset
units to the right of
.B Q.
.SH "EXAMPLES"
Source file example.pic:
.P
.B "  \edocumentclass{article}"
.br
.B "  \eusepackage{tikz}"
.br
.B "  \ebegin{document}"
.br
.B "  .PS"
.br
.B "  box dashed \(tsHello\(ts \(tsWorld\(ts"
.br
.B "  .PE"
.br
.B "  \eend{document}"
.P
The command
.BR
.P
.B "   dpic \-g example.pic > example.tex; pdflatex example"

produces example.pdf containing a dashed box with Hello and World
stacked inside.
.P
To produce a .tex file containing PSTricks drawing commands for
insertion into a LaTeX document using the \einput command,
delete the first three and last lines in the above source
and process using the
.B \-p
option of
dpic.
.P
Similarly, the picture source
.P
.B "  .PS"
.br
.B "  \edefinecolor{puce}{rgb}{0.8,0.53,0.6}%"
.br
.B "  box shaded \(tspuce\(ts"
.br
.B "  .PE"
.P
produces a box filled with a flea\(hylike color when processed with
.B "dpic \-g"
or
.B "dpic \-p"
and the resulting file is inserted into a latex source file invoking,
respectively, the tikz or pstricks package.
.SH "SEE ALSO"
.P
E. S. Raymond,
.I Making Pictures with GNU PIC,
1995.
.\" .br
In GNU groff source distribution;
.\" .br
http://www.kohala.com/start/troff/gpic.raymond.ps
.\" .br
(A good introduction to the pic language, with elementary
illustrations.)
.P
J. D. Aplevich,
.I Drawing with dpic,
2023,
.\" .br
http://ece.uwaterloo.ca/~aplevich/dpic/dpic-doc.pdf
.\" .br
(Specific discussion of dpic
facilities and extensions, with differences between dpic and GNU pic.)
.P
B. W. Kernighan, B. W. and D. M. Richie,
.I PIC \(hy A Graphics Language for Typesetting, User Manual,
1991.
.\" .br
AT&T Bell Laboratories,
Computing Science Technical Report
.\" .br
116.
(The original Unix
pic.)
.P
J. D. Aplevich,
.I M4 Macros for Electric Circuit Diagrams in LaTeX Documents,
2023.
File Circuit_macros.pdf in the graphics/Circuit_macros section
of CTAN repositories.
(Extension of the pic
language using the m4 macro processor for drawing electric circuits
and other diagrams.)
.\"
.SH AUTHOR
    Dwight Aplevich <aplevich at uwaterloo dot ca>
.\"   Copyright (c) 2023, J. D. Aplevich
.\"   .SH BSD licence:
.\"   .P
.\"   All rights reserved.
.\"   .P
.\"   Redistribution and use in source and binary forms, with or without
.\"   modification, are permitted provided that the following conditions
.\"   are met:
.\"   .P
.\"   * Redistributions of source code must retain the above copyright
.\"   notice, this list of conditions and the following disclaimer.
.\"   .P
.\"   * Redistributions in binary form must reproduce the above copyright
.\"   notice, this list of conditions and the following disclaimer in the
.\"   documentation and/or other materials provided with the distribution.
.\"   .P
.\"   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
.\"   EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\"   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\"   PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
.\"   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\"   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\"   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\"   BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\"   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
.\"   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\"   ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" .LP
.\" LIKE ANYTHING ELSE THAT'S FREE, DPIC AND ITS ASSOCIATED UTILITIES ARE
.\" PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR
.\" IMPLIED. IN NO EVENT WILL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES
.\" RESULTING FROM THE USE OF THIS SOFTWARE.