summaryrefslogtreecommitdiffstats
path: root/src/preproc/pic/pic.1.man
blob: 727cbc347d21f9a0af5d4dc7e3be18f904aceafb (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
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
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
.TH @g@pic @MAN1EXT@ "@MDATE@" "groff @VERSION@"
.SH Name
@g@pic \- compile pictures for
.I troff
or TeX
.
.
.\" ====================================================================
.\" Legal Terms
.\" ====================================================================
.\"
.\" Copyright (C) 1989-2020 Free Software Foundation, Inc.
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of
.\" this manual under the conditions for verbatim copying, provided that
.\" the entire resulting derived work is distributed under the terms of
.\" a permission notice identical to this one.
.\"
.\" Permission is granted to copy and distribute translations of this
.\" manual into another language, under the above conditions for
.\" modified versions, except that this permission notice may be
.\" included in translations approved by the Free Software Foundation
.\" instead of in the original English.
.
.
.\" Save and disable compatibility mode (for, e.g., Solaris 10/11).
.do nr *groff_pic_1_man_C \n[.cp]
.cp 0
.
.\" Define fallback for groff 1.23's MR macro if the system lacks it.
.nr do-fallback 0
.if !\n(.f           .nr do-fallback 1 \" mandoc
.if  \n(.g .if !d MR .nr do-fallback 1 \" older groff
.if !\n(.g           .nr do-fallback 1 \" non-groff *roff
.if \n[do-fallback]  \{\
.  de MR
.    ie \\n(.$=1 \
.      I \%\\$1
.    el \
.      IR \%\\$1 (\\$2)\\$3
.  .
.\}
.rr do-fallback
.
.
.\" ====================================================================
.\" Definitions
.\" ====================================================================
.
.ie t \{\
.  ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
.  ds lx L\h'-0.36m'\v'-0.22v'\s-2A\s0\h'-0.15m'\v'0.22v'\*[tx]
.\}
.el \{\
.  ds tx TeX
.  ds lx LaTeX
.\}
.
.ie \n(.g .ds ic \/
.el       .ds ic \^
.
.
.\" ====================================================================
.SH Synopsis
.\" ====================================================================
.
.SY @g@pic
.RB [ \-CnSU ]
.RI [ file\~ .\|.\|.]
.YS
.
.
.SY @g@pic
.B \-t
.RB [ \-cCSUz ]
.RI [ file\~ .\|.\|.]
.YS
.
.
.SY @g@pic
.B \-\-help
.YS
.
.
.SY @g@pic
.B \-v
.
.SY @g@pic
.B \-\-version
.YS
.
.
.\" ====================================================================
.SH Description
.\" ====================================================================
.
The GNU implementation of
.I pic \" generic
is part of the
.MR groff @MAN1EXT@
document formatting system.
.
.I @g@pic
is a
.MR @g@troff @MAN1EXT@
preprocessor that translates descriptions of diagrammatic pictures
embedded in
.MR roff @MAN7EXT@
or \*[tx] input files into the language understood by \*[tx] or
.IR @g@troff .
.
It copies the contents of each
.I file
to the standard output stream,
except that lines between
.B .PS
and any of
.BR .PE ,
.BR .PF ,
or
.B .PY
are interpreted as picture descriptions in the
.I pic
language.
.
End a
.I @g@pic
picture with
.B .PE
to leave the drawing position at the bottom of the picture,
and with
.B .PF
or
.B .PY
to leave it at the top.
.
Normally,
.I @g@pic
is not executed directly by the user,
but invoked by specifying the
.B \-p
option to
.MR groff @MAN1EXT@ .
.
If no
.I file
operands are given on the command line,
or if
.I file
is
.RB \[lq] \- \[rq],
the standard input stream is read.
.
.
.P
It is the user's responsibility to provide appropriate definitions
of the
.BR PS ,
.BR PE ,
and one or both of the
.B PF
and
.B PY
macros.
.
When a macro package does not supply these,
obtain simple definitions with the
.I groff
option
.BR \-mpic ;
these will center each picture.
.
.
.P
GNU
.I pic \" GNU
supports
.B PY
as a synonym of
.B PF
to work around a name space collision with the
.I mm
macro package,
which defines
.B PF
as a page footer management macro.
.
Use
.B PF
preferentially unless a similar problem faces your document.
.
.
.\" ====================================================================
.SH Options
.\" ====================================================================
.
.B \-\-help
displays a usage message,
while
.B \-v
and
.B \-\-version
show version information;
all exit afterward.
.
.
.TP
.B \-c
Be more compatible with
.IR tpic ;
implies
.BR \-t .
.
Lines beginning with
.B \[rs]
are not passed through transparently.
.
Lines beginning with
.B .\&
are passed through with the initial
.B .\&
changed to
.BR \[rs] .
.
A line beginning with
.B .ps
is given special treatment:
it takes an optional integer argument specifying the line thickness
(pen size)
in milliinches;
a missing argument restores the previous line thickness;
the default line thickness is 8\~milliinches.
.
The line thickness thus specified takes effect only when a
non-negative line thickness has not been specified by use of the
.B \%thickness
attribute or by setting the
.B \%linethick
variable.
.
.
.TP
.B \-C
Recognize
.BR .PS ,
.BR .PE ,
.BR .PF ,
and
.B .PY
even when followed by a character other than space or newline.
.
.
.TP
.B \-n
Don't use
.I groff
extensions to the
.I troff \" generic
drawing commands.
.
Specify this option if a postprocessor you're using doesn't support
these extensions,
described in
.MR groff_out @MAN5EXT@ .
.
This option also causes
.I @g@pic
not to use zero-length lines to draw dots in
.I troff \" generic
mode.
.
.
.TP
.B \-S
Operate in
.I safer mode;
.B sh
commands are ignored.
.
This mode,
enabled by default,
can be useful when operating on untrustworthy input.
.
.
.TP
.B \-t
Produce \*[tx] output.
.
.
.TP
.B \-U
Operate in
.I unsafe mode;
.B sh
commands are interpreted.
.
.
.TP
.B \-z
In \*[tx] mode,
draw dots using zero-length lines.
.
.
.P
The following options supported by other versions of
.I pic \" generic
are ignored.
.
.
.TP
.B \-D
Draw all lines using the \[rs]D escape sequence.
GNU
.I pic \" GNU
always does this.
.
.TP
.BI \-T\~ dev
Generate output for the
.I troff \" generic
device
.IR dev .
.
This is unnecessary because the
.I troff \" generic
output generated by
GNU
.I pic \" GNU
is device-independent.
.
.
.\" ====================================================================
.SH Usage
.\" ====================================================================
.
This section primarily discusses the differences between GNU
.I pic \" GNU
and the Eighth Edition Research Unix version of AT&T
.I pic \" AT&T
(1985).
.
Many of these differences also apply to later versions of AT&T
.IR pic .
.
.
.\" ====================================================================
.SS "\*[tx] mode"
.\" ====================================================================
.
\*[tx]-compatible output is produced when the
.B \-t
option is specified.
.
You must use a \*[tx] driver that supports
.I tpic
version 2 specials.
.
.RI ( tpic
was a fork of AT&T
.I pic \" AT&T
by Tim Morgan of the University of California at Irvine that diverged
from its source around 1984.
.
It is best known today for lending its name to a group of
.B \[rs]special
commands it produced for \*[tx].)
.\" http://ftp.cs.stanford.edu/tex/texhax/texhax90.019
.
.
.P
Lines beginning with
.B \[rs]
are passed through transparently;
a
.B %
is added to the end of the line to avoid unwanted spaces.
.
You can safely use this feature to change fonts or the value of
.BR \[rs]baselineskip .
.
Anything else may well produce undesirable results;
use at your own risk.
.
By default,
lines beginning with a dot are not treated specially\[em]but see the
.B \-c
option.
.
.
.P
In \*[tx] mode,
.I @g@pic
will define a vbox called
.B \[rs]graph
for each picture.
.
Use GNU
.IR pic 's \" GNU
.B figname
command to change the name of the vbox.
.
You must print that vbox yourself using the command
.
.RS
.EX
\[rs]centerline{\[rs]box\[rs]graph}
.EE
.RE
.
for instance.
.
Since the vbox has a height of zero
(it is defined with
.BR \[rs]vtop )
this will produce slightly more vertical space above the picture than
below it;
.
.RS
.EX
\[rs]centerline{\[rs]raise 1em\[rs]box\[rs]graph}
.EE
.RE
.
would avoid this.
.
To give the vbox a positive height and a depth of zero
(as used by \*[lx]'s
.IR \%graphics.sty ,
for example)
define the following macro in your document.
.
.RS
.EX
\[rs]def\[rs]gpicbox#1{%
  \[rs]vbox{\[rs]unvbox\[rs]csname #1\[rs]endcsname\[rs]kern 0pt}}
.EE
.RE
.
You can then simply say
.B \[rs]gpicbox{graph}
instead of
.BR \[rs]box\[rs]graph .
.
.
.\" ====================================================================
.SS Commands
.\" ====================================================================
.
Several commands new to GNU
.I pic \" GNU
accept delimiters,
shown in their synopses as braces
.BR "{ }" .
.
Nesting of braces is supported.
.
Any other characters
(except a space,
tab,
or newline)
.\" XXX even crazy control characters, ugh--src/preproc/pic/lex.cpp:1266
may be used as alternative delimiters,
in which case the members of a given pair must be identical.
.
Strings are recognized within delimiters of either kind;
they may contain the delimiter character or unbalanced braces.
.
.
.TP
\fBfor\fR \fIvariable\fR \fB=\fR \fIexpr1\fR \fBto\fR \fIexpr2\fR \
[\fBby\fR [\fB*\fR]\,\fIexpr3\/\fR] \fBdo\fR \fIX\fR \fIbody\fR \fIX\fR
Set
.I variable
to
.IR expr1 .
.
While the value of
.I variable
is less than or equal to
.IR expr2 ,
do
.I body
and increment
.I variable
by
.IR expr3 ;
if
.B by
is not given,
increment
.I variable
by 1.
.
If
.I expr3
is prefixed by
.B *
then
.I variable
will instead be multiplied by
.IR expr3 .
.
The value of
.I expr3
can be negative for the additive case;
.I variable
is then tested whether it is greater than or equal to
.IR expr2 .
.
For the multiplicative case,
.I expr3
must be greater than zero.
.
If the constraints aren't met,
the loop isn't executed.
.
.I X
can be any character not occurring in
.IR body .
.
.TP
\fBif\fR \fIexpr\fR \fBthen\fR \fIX\fR \fIif-true\fR \fIX\fR \
[\fBelse\fR \fIY\fR \fIif-false\fR \fIY\fR]
Evaluate
.IR expr ;
if it is non-zero then do
.IR if-true ,
otherwise do
.IR if-false .
.
.I X
can be any character not occurring in
.IR if-true .
.
.I Y
can be any character not occurring in
.IR if-false .
.
.TP
.BI print\~ arg\c
\~.\|.\|.
Concatenate and write arguments to the standard error stream followed by
a newline.
.
Each
.I arg
must be an expression,
a position,
or text.
.
This is useful for debugging.
.
.TP
.BI command\~ arg\c
\~.\|.\|.
.\" Move right margin to indentation since we must indent more later.
.RS
Concatenate arguments
and pass them as a line to
.I troff \" generic
or \*[tx].
.
Each
.I arg
must be an expression,
a position,
or text.
.
.B command
allows the values of
.I pic
variables to be passed to the formatter.
.
For example,
.
.RS
.EX
\&.PS
x = 14
command ".ds string x is " x "."
\&.PE
\[rs]*[string]
.EE
.RE
.
produces
.
.RS
.EX
x is 14.
.EE
.RE
when formatted with
.IR troff . \" generic
.RE
.
.
.TP
\fBsh\fR \fIX\fR \fIcommand\fR \fIX\fR
Pass
.I command
to a shell.
.
.
.TP
\fBcopy\fR \fB"\,\fIfilename\/\fB"\fR
Include
.I filename
at this point in the file.
.
.
.TP
.BR copy\~ [ \[dq]\c
.IB filename \[dq]\c
.RB ]\~ thru\~\c
.IR "X body X" \~\c \" space in roman: we must use 2-font macro with \c
.RB [ until\~ \[dq]\c
.IB word \[dq]\c
]
.TQ
.BR copy\~ [ \[dq]\c
.IB filename \[dq]\c
.RB ]\~ thru\~\c
.IR macro \~\c \" space roman because we must use 2-font macro with \c
.RB [ until\~ \[dq]\c
.IB word \[dq]\c
]
.\" Move right margin to indentation since we must indent more later.
.RS
This construct does
.I body
once for each line of
.IR filename ;
the line is split into blank-delimited words,
and occurrences of
.BI $ i
in
.IR body ,
for
.I i
between 1 and 9,
are replaced by the
.IR i -th
word of the line.
.
If
.I filename
is not given,
lines are taken from the current input up to
.BR .PE .
.
If an
.B until
clause is specified,
lines will be read only until a line the first word of which is
.IR word ;
that line will then be discarded.
.
.I X
can be any character not occurring in
.IR body .
.
For example,
.
.RS \" now move further
.EX
\&.PS
copy thru % circle at ($1,$2) % until "END"
1 2
3 4
5 6
END
box
\&.PE
.EE
.RE
.
and
.
.RS
.EX
\&.PS
circle at (1,2)
circle at (3,4)
circle at (5,6)
box
\&.PE
.EE
.RE
.
are equivalent.
.
The commands to be performed for each line can also be taken from a
macro defined earlier by giving the name of the macro as the argument to
.BR thru .
.
The argument after
.B thru
is looked up as a macro name first;
if not defined,
its first character is interpreted as a delimiter.
.RE
.
.
.TP
.B reset
.TQ
.BI reset\~ pvar1\c
.RB [ , ]\~\c
.IR pvar2 \~.\|.\|.
Reset predefined variables
.IR pvar1 ,
.I pvar2
\&.\|.\|.\& to their default values;
if no arguments are given,
reset all predefined variables to their default values.
.
Variable names may be separated by commas,
spaces,
or both.
.
Assigning a value to
.B scale
also causes all predefined variables that control dimensions to be reset
to their default values times the new value of
.BR scale .
.
.
.TP
\fBplot\fR \fIexpr\fR [\fB"\,\fItext\*(ic\fB"\fR]
This is a text object which is constructed by using
.I text
as a format string for sprintf
with an argument of
.IR expr .
.
If
.I text
is omitted a format string of
.B \[dq]%g\[dq]
is used.
.
Attributes can be specified in the same way as for a normal text
object.
Be very careful that you specify an appropriate format string;
.I @g@pic
does only very limited checking of the string.
.
This is deprecated in favour of
.BR sprintf .
.
.TP
.IB var \~:=\~ expr
.RS
This syntax resembles variable assignment with
.B =
except that
.I var
must already be defined,
and
.I expr
will be assigned to
.I var
without creating a variable local to the current block.
.
(By contrast,
.B =
defines
.I var
in the current block if it is not already defined there,
and then changes the value in the current block only.)
.
For example,
.
.RS
.EX
.B .PS
.B x = 3
.B y = 3
.B [
.B   x := 5
.B   y = 5
.B ]
.B print x " " y
.B .PE
.EE
.RE
.
writes
.
.RS
.EX
5 3
.EE
.RE
.
to the standard error stream.
.RE
.
.
.\" ====================================================================
.SS Expressions
.\" ====================================================================
.
The syntax for expressions has been significantly extended.
.
.
.P
.IB  x\  \[ha]\  y
(exponentiation)
.br
.BI sin( x )
.br
.BI cos( x )
.br
.BI atan2( y , \ x )
.br
.BI log( x )
(base 10)
.br
.BI exp( x )
(base 10, i.e.\&
.ie t 10\v'-.4m'\fIx\*(ic\fR\v'.4m')
.el   10\[ha]\fIx\fR)
.br
.BI sqrt( x )
.br
.BI int( x )
.br
.B rand()
(return a random number between 0 and 1)
.br
.BI rand( x )
(return a random number between 1 and
.IR x ;
deprecated)
.br
.BI srand( x )
(set the random number seed)
.br
.BI max( e1 , \ e2 )
.br
.BI min( e1 , \ e2 )
.br
.BI ! e
.br
\fIe1\fB && \fIe2\fR
.br
\fIe1\fB || \fIe2\fR
.br
\fIe1\fB == \fIe2\fR
.br
\fIe1\fB != \fIe2\fR
.br
\fIe1\fB >= \fIe2\fR
.br
\fIe1\fB > \fIe2\fR
.br
\fIe1\fB <= \fIe2\fR
.br
\fIe1\fB < \fIe2\fR
.br
\fB"\,\fIstr1\*(ic\fB" == "\,\fIstr2\*(ic\fB"\fR
.br
\fB"\,\fIstr1\*(ic\fB" != "\,\fIstr2\*(ic\fB"\fR
.br
.
.
.LP
String comparison expressions must be parenthesised in some contexts
to avoid ambiguity.
.
.
.\" ====================================================================
.SS "Other changes"
.\" ====================================================================
.
A bare expression,
.IR expr ,
is acceptable as an attribute;
it is equivalent to
.IR dir\ expr ,
where
.I dir
is the current direction.
.
For example
.LP
.RS
.B line 2i
.RE
.LP
means draw a line 2\ inches long in the current direction.
.
The \[oq]i\[cq]
(or \[oq]I\[cq])
character is ignored;
to use another measurement unit,
set the
.I scale
variable to an appropriate value.
.
.
.LP
The maximum width and height of the picture are taken from the variables
.B maxpswid
and
.BR maxpsht .
.
Initially,
these have values 8.5 and 11.
.
.
.LP
Scientific notation is allowed for numbers.
For example
.
.
.RS
.LP
.B
x = 5e\-2
.RE
.
.
.LP
Text attributes can be compounded.
.
For example,
.
.RS
.LP
.B
"foo" above ljust
.RE
.
.
.LP
is valid.
.
.
.LP
There is no limit to the depth to which blocks can be examined.
.
For example,
.RS
.LP
.EX
[A: [B: [C: box ]]] with .A.B.C.sw at 1,2
circle at last [\^].A.B.C
.EE
.RE
.
.
.LP
is acceptable.
.
.
.LP
Arcs now have compass points determined by the circle of which the arc
is a part.
.
.
.LP
Circles,
ellipses,
and arcs can be dotted or dashed.
.
In \*[tx] mode splines can be dotted or dashed also.
.
.
.LP
Boxes can have rounded corners.
.
The
.B rad
attribute specifies the radius of the quarter-circles at each corner.
If no
.B rad
or
.B diam
attribute is given,
a radius of
.B boxrad
is used.
.
Initially,
.B boxrad
has a value of\ 0.
.
A box with rounded corners can be dotted or dashed.
.
.
.LP
Boxes can have slanted sides.
.
This effectively changes the shape of a box from a rectangle to an
arbitrary parallelogram.
.
The
.B xslanted
and
.B yslanted
attributes specify the x and y\~offset of the box's upper right
corner from its default position.
.
.
.LP
The
.B .PS
line can have a second argument specifying a maximum height for
the picture.
.
If the width of zero is specified the width will be ignored in computing
the scaling factor for the picture.
.
GNU
.I pic \" GNU
will always scale a picture by the same amount vertically as well as
horizontally.
.
This is different from DWB 2.0
.I pic \" foreign
which may scale a picture by a different amount vertically than
horizontally if a height is specified.
.
.
.LP
Each text object has an invisible box associated with it.
.
The compass points of a text object are determined by this box.
.
The implicit motion associated with the object is also determined
by this box.
.
The dimensions of this box are taken from the width and height
attributes;
if the width attribute is not supplied then the width will be taken to
be
.BR textwid ;
if the height attribute is not supplied then the height will be taken to
be the number of text strings associated with the object times
.BR textht .
.
Initially,
.B textwid
and
.B textht
have a value of 0.
.
.
.LP
In
(almost all)
places where a quoted text string can be used,
an expression of the form
.
.
.IP
.BI sprintf(\[dq] format \[dq],\~ arg ,\fR\~.\|.\|.\fB)
.
.
.LP
can also be used;
this will produce the arguments formatted according to
.IR format ,
which should be a string as described in
.MR printf 3
appropriate for the number of arguments supplied.
.
Only the modifiers
.RB \[lq] # \[rq],
.RB \[lq] \- \[rq],
.RB \[lq] + \[rq],
and \[lq]\~\[rq] [space]),
a minimum field width,
an optional precision,
and the conversion specifiers
.BR %e ,
.BR %E ,
.BR %f ,
.BR %g ,
.BR %G ,
and
.B %%
are supported.
.
.
.LP
The thickness of the lines used to draw objects is controlled by the
.B linethick
variable.
.
This gives the thickness of lines in points.
.
A negative value means use the default thickness:
in \*[tx] output mode,
this means use a thickness of 8 milliinches;
in \*[tx] output mode with the
.B \-c
option,
this means use the line thickness specified by
.B .ps
lines;
in
.I troff
output mode,
this means use a thickness proportional to the pointsize.
.
A zero value means draw the thinnest possible line supported by
the output device.
.
Initially,
it has a value of \-1.
.
There is also a
.BR thick [ ness ]
attribute.
.
For example,
.
.
.RS
.LP
.B circle thickness 1.5
.RE
.
.
.LP
would draw a circle using a line with a thickness of 1.5 points.
.
The thickness of lines is not affected by the
value of the
.B scale
variable,
nor by the width or height given in the
.B .PS
line.
.
.
.LP
Boxes
(including boxes with rounded corners or slanted sides),
circles and ellipses can be filled by giving them an attribute of
.BR fill [ ed ].
.
This takes an optional argument of an expression with a value between
0 and 1;
0 will fill it with white,
1 with black,
values in between with a proportionally gray shade.
.
A value greater than 1 can also be used:
this means fill with the
shade of gray that is currently being used for text and lines.
.
Normally this will be black,
but output devices may provide a mechanism for changing this.
.
Without an argument,
then the value of the variable
.B \%fillval
will be used.
.
Initially,
this has a value of 0.5.
.
The invisible attribute does not affect the filling of objects.
.
Any text associated with a filled object will be added after the object
has been filled,
so that the text will not be obscured by the filling.
.
.
.P
Additional modifiers are available to draw colored objects:
.BR \%outline [ d ]
sets the color of the outline,
.B shaded
the fill color,
and
.BR colo [ u ] r [ ed ]
sets both.
.
All expect a subsequent string argument specifying the color.
.
.RS
.EX
circle shaded \[dq]green\[dq] outline \[dq]black\[dq]
.EE
.RE
.
Color is not yet supported in \*[tx] mode.
.
Device macro files like
.I ps.tmac
declare color names;
you can define additional ones with the
.B \%defcolor
request
(see
.MR groff @MAN7EXT@ ).
.
.
.LP
To change the name of the vbox in \*[tx] mode,
set the pseudo-variable
.B \%figname
(which is actually a specially parsed command)
within a picture.
.
Example:
.RS
.LP
.B .PS
.br
.B figname = foobar;
.br
.B ...
.br
.B .PE
.RE
.
.
.LP
The picture is then available in the box
.BR \[rs]foobar .
.
.
.LP
.I @g@pic
assumes that at the beginning of a picture both glyph and fill color are
set to the default value.
.
.
.LP
Arrow heads will be drawn as solid triangles if the variable
.B arrowhead
is non-zero and either \*[tx] mode is enabled or the
.B \-n
option has not been given.
.
Initially,
.B arrowhead
has a value of\ 1.
.
Solid arrow heads are always filled with the current outline color.
.
.
.LP
The
.I troff
output of
.I @g@pic
is device-independent.
.
The
.B \-T
option is therefore redundant.
.
All numbers are taken to be in inches;
numbers are never interpreted to be in
.I troff
machine units.
.
.
.LP
Objects can have an
.B aligned
attribute.
.
This will only work if the postprocessor is
.MR grops @MAN1EXT@
or
.MR gropdf @MAN1EXT@ .
.
Any text associated with an object having the
.B aligned
attribute will be rotated about the center of the object
so that it is aligned in the direction from the start point
to the end point of the object.
.
This attribute will have no effect on objects whose start and end points
are coincident.
.
.
.LP
In places where
.IB n th
is allowed,
.BI \[aq] expr \[aq]th
is also allowed.
.
.RB \[lq] \[aq]th \[lq]
is a single token:
no space is allowed between the apostrophe and the
.RB \[lq] th \[rq].
.
.
For example,
.IP
.EX
for i = 1 to 4 do {
   line from \[aq]i\[aq]th box.nw to \[aq]i+1\[aq]th box.se
}
.EE
.
.
.\" ====================================================================
.SH Conversion
.\" ====================================================================
.
To obtain a stand-alone picture from a
.I @g@pic
file,
enclose your
.I pic \" language
code with
.B .PS
and
.B .PE
requests;
.I roff
configuration commands may be added at the beginning of the file,
but no
.I roff
text.
.
.
.LP
It is necessary to feed this file into
.I groff
without adding any page information,
so you must check which
.B .PS
and
.B .PE
requests are actually called.
.
For example,
the
.I mm
macro package adds a page number,
which is very annoying.
.
At the moment,
calling standard
.I groff
without any macro package works.
.
Alternatively,
you can define your own requests,
e.g.,
to do nothing:
.
.
.LP
.RS
.EX
\&.de PS
\&..
\&.de PE
\&..
.EE
.RE
.
.
.LP
.I groff
itself does not provide direct conversion into other graphics file
formats.
.
But there are lots of possibilities if you first transform your
picture into PostScript\*R format using the
.I groff
option
.BR \-Tps .
.
Since this
.IR ps -file
lacks BoundingBox information it is not very useful by itself, but it
may be fed into other conversion programs, usually named
.BI ps2 other
or
.BI psto other
or the like.
.
Moreover,
the PostScript interpreter Ghostscript
.RI ( gs (1))
has built-in graphics conversion devices that are called with the option
.
.
.LP
.RS
.BI "gs \-sDEVICE=" <devname>
.RE
.
.
.LP
Call
.
.
.LP
.RS
.B gs \-\-help
.RE
.
.
.LP
for a list of the available devices.
.
.
.LP
An alternative may be to use the
.B \-Tpdf
option to convert your picture directly into
.B PDF
format.
.
The MediaBox of the file produced can be controlled by passing a
.B \-P\-p
papersize to
.IR groff .
.
.
.br
.ne 3v
.P
As the Encapsulated PostScript File Format
.B EPS
is getting more and more important,
and the conversion wasn't regarded trivial in the past you might be
interested to know that there is a conversion tool named
.I ps2eps
which does the right job.
.
It is much better than the tool
.I ps2epsi
packaged with
.IR gs .
.
.
.LP
For bitmapped graphic formats,
you should use
.IR pstopnm ;
the resulting (intermediate)
.MR pnm 5
file can be then converted to virtually any graphics format using the
tools of the
.B netpbm
package.
.
.
.\" ====================================================================
.SH Files
.\" ====================================================================
.
.TP
.I @MACRODIR@/pic.tmac
offers simple definitions of the
.BR PS ,
.BR PE ,
.BR PF ,
and
.B PY
macros.
.
.
.\" ====================================================================
.SH Bugs
.\" ====================================================================
.
Characters that are invalid as input to GNU
.I troff \" GNU
(see the
.I groff
Texinfo manual or
.MR groff_char @MAN7EXT@
for a list)
are rejected even in \*[tx] mode.
.
.
.LP
The interpretation of
.B \%fillval
is incompatible with the
.I pic \" AT&T
in Tenth Edition Research Unix,
which interprets 0 as black and 1 as white.
.
.
.\" ====================================================================
.SH "See also"
.\" ====================================================================
.
.TP
.I @DOCDIR@/\:pic\:.ps
\[lq]Making Pictures with GNU pic\[rq],
by Eric S.\& Raymond.
.
This file,
together with its source,
.IR pic.ms ,
is part of the
.I groff
distribution.
.
.
.P
\[lq]PIC\[em]A Graphics Language for Typesetting: User Manual\[rq],
by Brian W.\& Kernighan,
1984
(revised 1991),
AT&T Bell Laboratories Computing Science Technical Report No.\& 116
.
.
.P
.I ps2eps
is available from CTAN mirrors, e.g.,
.UR ftp://\:ftp\:.dante\:.de/\:tex\-archive/\:support/\:ps2eps/
.UE
.
.
.LP
W.\& Richard Stevens,
.UR http://\:www\:.kohala\:.com/\:start/\:troff/\:pic2html\:.html
.I Turning PIC into HTML
.UE
.
.
.LP
W.\& Richard Stevens,
.UR http://\:www\:.kohala\:.com/\:start/\:troff/\:pic\:.examples\:.ps
.IR "Examples of " pic " Macros"
.UE
.
.
.LP
.MR @g@troff @MAN1EXT@ ,
.MR groff_out @MAN5EXT@ ,
.MR tex 1 ,
.MR gs 1 ,
.MR ps2eps 1 ,
.MR pstopnm 1 ,
.MR ps2epsi 1 ,
.MR pnm 5
.
.
.\" Clean up.
.rm tx
.rm lx
.rm ic
.
.\" Restore compatibility mode (for, e.g., Solaris 10/11).
.cp \n[*groff_pic_1_man_C]
.do rr *groff_pic_1_man_C
.
.
.\" Local Variables:
.\" fill-column: 72
.\" mode: nroff
.\" End:
.\" vim: set filetype=groff textwidth=72: