Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

postscriptlight.rst 47 KB

You have to be logged in to leave a comment. Sign In
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
  1. .. index:: ! postscriptlight
  2. ***************
  3. PostScriptLight
  4. ***************
  5. PSL 6.0 - A PostScript based plotting library
  6. Description
  7. -----------
  8. PSL (PostScriptLight) was created to make the generation of PostScript page
  9. description code easier. PS is a page description language developed by
  10. the Adobe for specifying how a printer should render a page of text or
  11. graphics. It uses a reverse Polish notation that puts and gets items
  12. from a stack to draws lines, text, and images and even performs
  13. calculations. PSL is a self-contained library that presents a series
  14. of functions that can be used to create plots. The resulting
  15. PostScript code is ASCII text (with some exceptions for images if so
  16. desired) and can thus be edited using any text editor. Thus, it is
  17. possible to modify a plot file even after it has been created, e.g., to
  18. change text strings, set new gray shades or colors, experiment with
  19. various pen widths, etc. Furthermore, various tools exist that can parse
  20. PostScript and let you make such edits via a graphical user interface
  21. (e.g., Adobe Illustrator). PSL is written in C but includes FORTRAN
  22. bindings and can therefore be called from both C and FORTRAN programs.
  23. To use this library, you must link your plotting program with PSL.
  24. PSL is used by the GMT graphics programs to generate PS. PSL
  25. output is freeform PostScript that conforms to the Adobe PostScript
  26. File Specification Version 3.0.
  27. Before any PSL calls can be issued, the plotting system must be
  28. initialized. This is done by calling **PSL_beginsession**, which
  29. initializes a new PSL session; then call **PSL_setdefaults** which
  30. sets internal variables and default settings, accepts settings for
  31. measurement units and character encoding, and returns a pointer to a
  32. struct PSL_CTRL which must be passed as first argument to all other
  33. PSL functions. The measure unit for sizes and positions can be set
  34. to be centimeter (c), inch (i), meter (m), or points
  35. (p). A PSL session is terminated by calling
  36. **PSL_endsession**. You may create one or more plots within the same
  37. session. A new plot is started by calling **PSL_beginplot**, which
  38. defines macros, sets up the plot-coordinate system, scales, and
  39. [optionally] opens a file where all the PS code will be written.
  40. Normally, the plot code is written to *stdout*. When all plotting to
  41. this file is done, you finalize the plot by calling **PSL_endplot**.
  42. A wide variety of output devices that support PostScript exist,
  43. including many printers and large-format plotters. Many tools exists to
  44. display PostScript on a computer screen. Open source tools such as
  45. ghostscript can be used to convert PostScript into PDF or raster
  46. images (e.g., TIFF, JPEG) at a user-defined resolution (DPI). In
  47. particular, the GMT tool :doc:`psconvert` is a front-end to ghostscript and
  48. pre-selects the optimal options for ghostscript that will render quality
  49. PDF and images.
  50. The PSL is fully 64-bit compliant. Integer parameters are here
  51. specified by the type **long** to distinguish them from the 32-bit
  52. **int**. Note that under standard 32-bit compilation they are
  53. equivalent. Users of this library under 64-bit mode must make sure they
  54. pass proper **long** variables (under Unix flavors) or **\_\_int64**
  55. under Windows 64.
  56. Units
  57. -----
  58. PSL can be instructed to use centimeters, inches, meters or points
  59. as input units for the coordinates and sizes of elements to be plotted.
  60. Any dimension that takes this setting as a unit is specified as *user
  61. units* or *plot units* in this manual. Excluded from this are line
  62. widths and font sizes which are always measured in *points*. The user
  63. units can be further refined by calling **PSL_beginaxes**, giving the
  64. user the opportunity to specify any linear coordinate frame. Changing
  65. the coordinate frame only affects the coordinates of plotted material
  66. indicated as measured in *plot units*, not the sizes of symbols (which
  67. remain in *user units*), nor line widths or font sizes (which remain in
  68. *points*).
  69. Color
  70. -----
  71. PSL uses the direct color model where red, green, and blue are given
  72. separately, each must be in the range from 0-1. If red = -1 then no fill
  73. operation takes place. If red = -3, then pattern fill will be used, and
  74. the green value will indicate the pattern to be used. Most plot-items
  75. can be plotted with or without outlines. If outline is desired (i.e.,
  76. set to 1), it will be drawn using the current line width and pattern.
  77. PSL uses highly optimized macro substitutions and scales the
  78. coordinates depending on the resolution of the hardcopy device so that
  79. the output file is kept as compact as possible.
  80. Justification
  81. -------------
  82. Text strings, text boxes and images can be "justified" by specifying the
  83. corner to which the *x* and *y* coordinates of the subroutine call
  84. apply. Nine different values are possible, as shown schematically in
  85. this diagram:
  86. ::
  87. 9 ------------ 10 ----------- 11
  88. | |
  89. 5 6 7
  90. | |
  91. 1 ------------ 2 ------------ 3
  92. The box represents the text or image. E.g., to plot a text string with
  93. its center at (*x*, *y*), you must use *justify* == 6. *justify* == 0
  94. means "no justification", which generally means (*x*, *y*) is at the
  95. bottom left. Convenience values PSL_NONE, PSL_BL, PSL_BC, PSL_BL,
  96. PSL_ML, PSL_MC, PSL_MR, PSL_TL, PSL_TC and PSL_TR are available.
  97. Initialization
  98. --------------
  99. These functions initialize or terminate the PSL system. We use the
  100. term PSL session to indicate one instance of the PSL system (a
  101. complicated program could run many PSL sessions concurrently as each
  102. would operate via its own control structure). During a single session,
  103. one or more plots may be created. Here are the functions involved in
  104. initialization:
  105. **struct PSL_CTRL \*New_PSL_Ctrl** (**char** *\*session*)
  106. This is the first function that must be called as it creates a new
  107. PSL session. Specifically, it will allocate a new PSL
  108. control structure and initialize the session default parameters. The
  109. pointer that is returned must be passed to all subsequent PSL
  110. functions.
  111. **long \*PSL_beginsession** (**struct PSL_CTRL** *\*PSL*, **long**
  112. *search*, **char** *\*sharedir*, **char** *\*userdir*)
  113. This is the second function that must be called as it initializes
  114. the new PSL session. Here, *search* is an integer that is passed
  115. as 0 in GMT but should be 1 for other users. If so we will search
  116. for the environmental parameters PSL_SHAREDIR and PSL_USERDIR
  117. should the corresponding arguments *sharedir* and *userdir* be NULL.
  118. **long PSL_endsession** (**struct PSL_CTRL** *\*PSL*)
  119. This function terminates the active PSL session; it is the last
  120. function you must call in your program. Specifically, this function
  121. will deallocate memory used and free up resources.
  122. **struct PSL_CTRL \*PSL_beginlayer** (**struct PSL_CTRL** *\*PSL*,
  123. **long** *layer*)
  124. Adds a DSC comment by naming this layer; give a unique integer
  125. value. Terminate layer with PSL_endlayer
  126. **struct PSL_CTRL \*PSL_endlayer** (**struct PSL_CTRL** *\*PSL*)
  127. Terminate current layer with a DSC comment.
  128. **long PSL_fopen** (**char** *\*file*, **char** *\*mode*)
  129. This function simply opens a file, just like fopen. The reason it is
  130. replicated here is that under Windows, file pointers must be
  131. assigned within the same DLL as they are being used. Yes, this is
  132. retarded but if we do not do so then PSL will not work well under
  133. Windows. Under non-Windows this functions is just a macro that
  134. becomes fopen.
  135. **void PSL_copy** (**struct PSL_CTRL** *\*PSL*, **char** *\*text*);
  136. This functions simply adds the given *test* as is to the output
  137. PostScript stream (or internal buffer). It is used when the
  138. text may exceed the internal 4096 buffer used in PSL_command
  139. (which is implemented as a printf function and hence a buffer
  140. of fixed size is used.)
  141. **void PSL_free** (**void** *\*ptr*)
  142. This function frees up the memory allocated inside PSL.
  143. Programmers using C/C++ should now this is a macro and there is no
  144. need to cast the pointer to *void \** as this will be done by the
  145. macro. Fortran programmers should instead call
  146. **PSL_freefunction**.
  147. **void PSL_beginaxes** (**struct PSL_CTRL** *\*PSL*, **double** *llx*,
  148. **double** *lly*, **double** *width*, **double** *height*, **double**
  149. *x0*, **double** *y0*, **double** *x1*, **double** *y1*)
  150. This function sets up the mapping that takes the users data
  151. coordinates and converts them to the positions on the plot in
  152. PostScript units. This should be used when plotting data
  153. coordinates and is terminated with **PSL_endaxes**, which returns
  154. PSL to the default measurement units and scaling. Here, *llx*
  155. and *lly* sets the lower left position of the mapping region, while
  156. *width* and *height* sets the dimension of the plot area in user
  157. units. Finally, *x0*, *x1* and *y0*, *y1* indicate the range of the
  158. users x- and y-coordinates, respectively. Specify a reverse axis
  159. direction (e.g., to let the y-axis be positive down) by setting *y0*
  160. larger than *y1*, and similarly for an x-axis that increases to the
  161. left.
  162. **void PSL_endaxes** (**struct PSL_CTRL** *\*PSL*)
  163. Terminates the map scalings initialized by **PSL_beginaxes** and
  164. returns PSL to standard scaling in measurement units.
  165. **long PSL_beginplot** (**struct PSL_CTRL** *\*P*, **FILE** *\*fp*,
  166. **long** *orientation*, **long** *overlay*, **long** *color_mode*,
  167. **char** *origin*\ [], **double** *offset*\ [], **double**
  168. *page_size*\ [], **char** *\*title*, **long** *font_no*\ [])
  169. Controls the initiation (or continuation) of a particular plot
  170. within the current session. Pass file pointer *fp* where the
  171. PostScript code will be written; if NULL then the output is
  172. written to *stdout*. The Fortran interface always sends to *stdout*.
  173. If you want to receive the PostScript back in memory then you need
  174. to add PSL_MEMORY to *orientation* and call **PSL_getplot** to retrieve
  175. the plot after you finish the plot with **PSL_endplot**.
  176. The *orientation* may be landscape (PSL_LANDSCAPE or 0) or portrait
  177. (PSL_PORTRAIT or 1). Set *overlay* to PSL_OVERLAY (0) if the
  178. following PostScript code should be appended to an existing plot;
  179. otherwise pass PSL_INIT (1) to start a new plot.
  180. Let *colormode* be one of PSL_RGB (0), PSL_CMYK
  181. (1), PSL_HSV (2) or PSL_GRAY (3); this setting controls how colors
  182. are presented in the PostScript code. The *origin* setting
  183. determines for x and y separately the origin of the specified
  184. offsets (next argument). Each of the two characters are either **r**
  185. for an offset relative to the current origin, **a** for a temporary
  186. adjustment of the origin which is undone during BD(PSL_endplot),
  187. **f** for a placement of the origin relative to the lower left corner
  188. of the page, **c** for a placement of the origin relative to the
  189. center of the page. The array *offset* specifies the offset of the
  190. new origin relative to the position indicated by **origin**.
  191. *page_size* means the physical width and height of the plotting
  192. media in points (typically 612 by 792 for Letter or 595 by 842 for
  193. A4 format). The character string *title* can be used to specify the
  194. **%%Title:** header in the PostScript file (or use NULL for the
  195. default). The array *font_no* specifies all fonts used in the plot
  196. (by number), or use NULL to leave out the
  197. **%%DocumentNeededResources:** comment in the PostScript file.
  198. **long PSL_endplot** (**struct PSL_CTRL** *\*P*, **long** *last_page*)
  199. Terminates the plotting sequence and closes plot file (if other than
  200. *stdout*). If *last_page* == PSL_FINALIZE
  201. (1), then a PostScript *showpage* command
  202. is issued, which initiates the printing process on hardcopy devices.
  203. Otherwise, pass PSL_OVERLAY (0).
  204. **long PSL_setorigin** (**struct PSL_CTRL** *\*P*, **double**
  205. *xorigin*, **double** *yorigin*, **double** *angle*, **long** *mode*)
  206. Changes the coordinate system by translating by
  207. (*xorigin*,\ *yorigin*) followed by a *angle*-degree rotation
  208. (*mode*\ =PSL_FWD or 0) or alternatively the rotation followed by
  209. translation (*mode*\ =PSL_INV or 1).
  210. Memory Output
  211. -------------
  212. Normally, PSL will write all PostScript to the designated file stream
  213. set in **PSL_beginplot**. Alternatively, PSL can write all the PostScript
  214. to an internal char * buffer which can be retrieved at the end of the plotting.
  215. This mode can be enabled on a plot-by-plot basis by adding the flag **PSL_MEMORY**
  216. to the variable *orientation* passed to **PSL_beginplot**. Once we reach the
  217. end of the plot with **PSL_endplot** the buffer will be available (see below).
  218. One function provide the functionality for memory output.
  219. **char * PSL_getplot** (**struct PSL_CTRL** *\*P*)
  220. Retrieves the pointer to the PostScript plot that is kept in memory
  221. when **PSL_beginplot** was instructed to use memory rather than
  222. stream output. **Note**: It is the responsibility of the programmer to
  223. ensure that the object retrieved is duplicated or written or otherwise
  224. processed before the next call to **PSL_beginplot** or **PSL_endsession**
  225. either of which will destroy the memory pointed to.
  226. Changing Settings
  227. -----------------
  228. The following functions are used to change various PSL settings and
  229. affect the current state of parameters such as line and fill attributes.
  230. **long PSL_define_pen** (**struct PSL_CTRL** *\*P*, **char**
  231. *\*name*, **long** *width*, **char** *\*style*, **double** *offset*,
  232. **double** *rgb*\ [])
  233. Stores the specified pen characteristics in a PostScript variable
  234. called *name*. This can be used to place certain pen attributes in
  235. the PostScript file and then retrieve them later with
  236. **PSL_load_pen**. This makes the stored pen the current pen.
  237. **long PSL_define_rgb** (**struct PSL_CTRL** *\*P*, **char**
  238. *\*name*, **double** *rgb*\ [])
  239. Stores the specified color in a PostScript variable called *name*.
  240. This can be used to place certain color values in the PostScript
  241. file and then retrieve them later with **PSL_load_rgb**. This
  242. makes the stored color the current color.
  243. **long PSL_setexec** (**struct PSL_CTRL** *\*P*, **long** *mode*)
  244. If *mode* = 1 then we tell PSL to execute a custom PostScript
  245. procedure named PSL_completion at the start of the next overlay.
  246. Once executed, the function is reset to a dummy null procedure.
  247. Experts may define their own procedure called PSL_completion
  248. and insert it into the PostScript stream. Changing the mode
  249. can then be used to have some tasks complete prior to the
  250. new overlay being generated.
  251. **long PSL_setcolor** (**struct PSL_CTRL** *\*P*, **double**
  252. *rgb*\ [], **long** *mode*)
  253. Sets the current color for all stroked (mode = PSL_IS_STROKE (0))
  254. or filled (mode = PSL_IS_FILL (1)) material
  255. to follow (lines, symbol outlines, text). *rgb* is a triplet of red,
  256. green and blue values in the range 0.0 through 1.0. Set the red
  257. color to -3.0 and the green color to the pattern number returned by
  258. **PSL_setimage** to select an image pattern as current paint color. For
  259. PDF transparency, set *rgb*\ [3] to a value between 0 (opaque) and 1
  260. (fully transparent).
  261. **long PSL_setcurrentpoint** (**struct PSL_CTRL** *\*P*, **double**
  262. *x*, **double** *y*)
  263. Sets the current point to the location given by (*x*, *y*).
  264. **long PSL_setimage** (**struct PSL_CTRL** *\*P*, **long**
  265. *image_no*, **char** *\*imagefile*, **unsigned char** *\*image*,
  266. **long** *dpi*, **long dim[3], **double** *f_rgb*\ [], **double** *b_rgb*\ [])
  267. Sets up the specified image pattern as the fill to use for polygons
  268. and symbols. Here, *image_no* is the number of the standard PSL
  269. fill patterns (1-90; use a negative number when you specify an image
  270. *filename* instead and pass the *image* data vector and the dimensions
  271. of the image via the *dim* array (width, height, and bit-depth).
  272. The scaling (i.e., resolution in dots per inch)
  273. of the pattern is controlled by the image *dpi*; if set to 0 it will
  274. be plotted at the device resolution. The last two arguments
  275. apply to 1-bit images only and are otherwise ignored: You may
  276. replace the foreground color (the set bits) with the *f_rgb* color
  277. and the background color (the unset bits) with *b_rgb*.
  278. Alternatively, pass either color with the red component set to -1.0
  279. and we will instead issue an image mask that is see-through for the
  280. specified fore- or background component. To subsequently use the
  281. pattern as a pen or fill color, use **PSL_setcolor** or
  282. DB(PSL_setfill) with the a color *rgb* code made up of *r* = -3,
  283. and *b* = the pattern number returned by **PSL_setimage**.
  284. **long PSL_setdash** (**struct PSL_CTRL** *\*P*, **char** *\*pattern*,
  285. **double** *offset*)
  286. Changes the current pen style attributes. The character string
  287. *pattern* contains the desired pattern using a series of lengths in
  288. points specifying the alternating lengths of dashes and gaps in
  289. points. E.g., "4 2" and *offset* = 1 will plot like
  290. x ---- ---- ----
  291. where x is starting point of a line (The x is not plotted). That is,
  292. the line is made up of a repeating pattern of a 4 points long solid
  293. line and a 2 points long gap, starting 1 point after the x. To reset
  294. to solid line, specify *pattern* = NULL ("") and *offset* = 0.
  295. **long PSL_setfill** (**struct PSL_CTRL** *\*P*, **double** *rgb*\ [],
  296. **long** *outline*)
  297. Sets the current fill color and whether or not outline is needed for
  298. symbols. Special cases are handled by passing the red color as -1.0
  299. (no fill), -2.0 (do not change the outline setting) or -3.0 (select
  300. the image pattern indicated by the second (green) element of *rgb*).
  301. For PDF transparency, set *rgb*\ [3] to a value between 0 (opaque)
  302. and 1 (fully transparent). Set outline to PSL_OUTLINE
  303. (1) to draw the outlines of polygons and symbols using the current pen,
  304. 0 to turn outline off, and -2 to leave existing setting as is.
  305. **long PSL_setfont** (**struct PSL_CTRL** *\*P*, **long** *fontnr*)
  306. Changes the current font number to *fontnr*. The fonts available
  307. are: 0 = Helvetica, 1 = H. Bold, 2 = H. Oblique, 3 = H.
  308. Bold-Oblique, 4 = Times, 5 = T. Bold, 6 = T. Italic, 7 = T. Bold
  309. Italic, 8 = Courier, 9 = C. Bold, 10 = C Oblique, 11 = C Bold
  310. Oblique, 12 = Symbol, 13 = AvantGarde-Book, 14 = A.-BookOblique, 15
  311. = A.-Demi, 16 = A.-DemiOblique, 17 = Bookman-Demi, 18 =
  312. B.-DemiItalic, 19 = B.-Light, 20 = B.-LightItalic, 21 =
  313. Helvetica-Narrow, 22 = H-N-Bold, 23 = H-N-Oblique, 24 =
  314. H-N-BoldOblique, 25 = NewCenturySchlbk-Roman, 26 = N.-Italic, 27 =
  315. N.-Bold, 28 = N.-BoldItalic, 29 = Palatino-Roman, 30 = P.-Italic, 31
  316. = P.-Bold, 32 = P.-BoldItalic, 33 = ZapfChancery-MediumItalic, 34 =
  317. ZapfDingbats, 35 = Ryumin-Light-EUC-H, 36 = Ryumin-Light-EUC-V, 37 =
  318. GothicBBB-Medium-EUC-H, and 38 = GothicBBB-Medium-EUC-V. If *fontnr*
  319. is outside this range, it is reset to 0.
  320. **long PSL_setfontdims** (**struct PSL_CTRL** *\*P*, **double** *supsub*,
  321. **double** *scaps*, **double** *sup*, **double** *sdown*)
  322. Changes the settings for a variety of relative font sizes and shifts
  323. pertaining to sub-scripts, super-scripts, and small caps. Default
  324. settings are given in brackets. Here, *supsub* sets the relative size
  325. of sub- and super-scripts [0.58], *scaps* sets the relative size of
  326. small caps [0.8], *sup* indicates the upward baseline shift for placement
  327. of super-scripts [0.33], while *sdown* sets the downward baseline shift
  328. for sub-scripts [0.33].
  329. **long PSL_setformat** (**struct PSL_CTRL** *\*P*, **long** *n_decimals*)
  330. Sets the number of decimals to be used when writing color or gray
  331. values. The default setting of 3 gives 1000 choices per red, green,
  332. and blue value, which is more than the 255 choices offered by most
  333. 24-bit platforms. Choosing a lower value will make the output file
  334. smaller at the expense of less color resolution. Still, a value of 2
  335. gives 100 x 100 x 100 = 1 million colors, more than most eyes can
  336. distinguish. For a setting of 1, you will have 10 nuances per
  337. primary color and a total of 1000 unique combinations.
  338. **long PSL_setlinewidth** (**struct PSL_CTRL** *\*P*, **double**
  339. *linewidth*)
  340. Changes the current line width in points. Specifying 0 gives the
  341. thinnest line possible, but this is implementation-dependent (seems
  342. to work fine on most PostScript printers).
  343. **long PSL_setlinecap** (**struct PSL_CTRL** *\*P*, **long** *cap*)
  344. Changes the current line cap, i.e., what happens at the beginning
  345. and end of a line segment. PSL_BUTT_CAP (0) gives butt line caps
  346. [Default], PSL_ROUND_CAP (1) selects round
  347. caps, while PSL_SQUARE_CAP (2) results
  348. in square caps. Thus, the two last options will visually lengthen a
  349. straight line-segment by half the line width at either end.
  350. **long PSL_setlinejoin** (**struct PSL_CTRL** *\*P*, **long** *join*)
  351. Changes the current linejoin setting, which handles how lines of
  352. finite thickness are joined together when the meet at different
  353. angles. PSL_MITER_JOIN (0) gives a mitered joint [Default],
  354. PSL_ROUND_JOIN (1) makes them round,
  355. while PSL_BEVEL_JOIN (2) produces bevel joins.
  356. **long PSL_setmiterlimit** (**struct PSL_CTRL** *\*P*, **long** *limit*)
  357. Changes the current miter limit used for mitered joins.
  358. PSL_MITER_DEFAULT (35) gives the default PS miter; other values
  359. are interpreted as the cutoff acute angle (in degrees) when mitering
  360. becomes active.
  361. **long PSL_settextmode** (**struct PSL_CTRL** *\*P*, **long** *mode*)
  362. Changes between the two modes PSL_TXTMODE_MINUS and PSL_TXTMODE_HYPHEN.
  363. When the minus mode is active we assume we are plotting annotation
  364. strings with numbers and all hyphens are translated to minus codes
  365. which differs based on char sets. Likewise, in hyphen mode any
  366. minus character is typeset as a hyphen in the current char set.
  367. **long PSL_settransparency** (**struct PSL_CTRL** *\*P*, **double**
  368. *\*transparency*)
  369. Changes the current PDF transparency value.
  370. **long PSL_settransparencymode** (**struct PSL_CTRL** *\*P*, **char**
  371. *\*mode*)
  372. Changes the current PDF transparency rendering mode [Default is
  373. Normal]. Choose among Color, ColorBurn, ColorDodge, Darken,
  374. Difference, Exclusion, HardLight, Hue, Lighten, Luminosity,
  375. Multiply, Normal, Overlay, Saturation, SoftLight, and Screen.
  376. **long PSL_setdefaults** (**struct PSL_CTRL** *\*P*, **double**
  377. *xyscales*\ [], **double** *pagergb*\ [], **char** *\*encoding*)
  378. Allows changes to the PSL session settings and should be called
  379. immediately after **PSL_beginsession**. The *xyscales* array affect
  380. an overall magnification of your plot [1,1]. This can be useful if
  381. you design a page-sized plot but would then like to magnify (or
  382. shrink) it by a given factor. Change the default paper media color
  383. [white; 1/1/1] by specifying an alternate page color. Passing zero
  384. (or NULL for *pagergb*) will leave the setting unchanged. Finally,
  385. pass the name of the character set encoding (if NULL we select
  386. Standard).
  387. **long PSL_defunits** (**struct PSL_CTRL** *\*P*, **char** *\*name*,
  388. **double** *value*)
  389. Creates a PostScript variable called *name* and initializes it to
  390. the equivalent of *value* user units.
  391. **long PSL_defpoints** (**struct PSL_CTRL** *\*P*, **char** *\*name*,
  392. **double** *fontsize*)
  393. Creates a PostScript variable called *name* and initializes it to
  394. the value that corresponds to the font size (in points) given by
  395. *fontsize*.
  396. Plotting Lines And Polygons
  397. ---------------------------
  398. Here are functions used to plot lines and closed polygons, which may
  399. optionally be filled. The attributes used for drawing and filling are
  400. set prior to calling these functions; see CHANGING SETTINGS above.
  401. **long PSL_plotarc** (**struct PSL_CTRL** *\*P*, **double** *x*,
  402. **double** *y*, **double** *radius*, **double** *angle1*, **double**
  403. *angle2*, **long** *type*)
  404. Draws a circular arc with its center at plot coordinates (*x*, *y*),
  405. starting from angle *angle1* and end at *angle2*. Angles must be
  406. given in decimal degrees. If *angle1* > *angle2*, a negative arc is
  407. drawn. The *radius* is in user units. The *type* determines how the
  408. arc is interpreted: PSL_MOVE (1) means set new
  409. anchor point, PSL_STROKE (2) means stroke
  410. the arc, PSL_MOVE + PSL_STROKE (3) means
  411. both, whereas PSL_DRAW (0) just adds to arc path to the current
  412. path.
  413. **long PSL_plotline** (**struct PSL_CTRL** *\*P*, **double** *x*,
  414. **double** *y*, **long** *n*, **long** *type*)
  415. Assemble a continuous line through *n* points whose the plot
  416. coordinates are in the *x*, *y* arrays. To continue an existing
  417. line, use *type* = PSL_DRAW (0), or if this is the first segment in
  418. a multisegment path, set *type* = PSL_MOVE (1).
  419. To end the segments and draw the lines, add PSL_STROKE
  420. (2). Thus, for a single segment, *type* must
  421. be PSL_MOVE + PSL_STROKE (3). The line is
  422. drawn using the current pen attributes. Add PSL_CLOSE
  423. (8) to *type* to close the first and last point
  424. by the PostScript operators; this is done automatically if the
  425. first and last point are equal.
  426. **long PSL_plotpoint** (**struct PSL_CTRL** *\*P*, **double** *x*,
  427. **double** *y*, **long** *type*)
  428. Moves the pen from the current to the specified plot coordinates
  429. (*x*, *y*) and optionally draws and strokes the line, depending on
  430. *type*. Specify *type* as either a move (PSL_MOVE, 1), or draw
  431. (PSL_DRAW, 2), or draw and stroke (PSL_DRAW + PSL_STOKE, 3) using
  432. current pen attributes. It the coordinates are relative to the
  433. current point add PSL_REL (4) to *type*.
  434. **long PSL_plotbox** (**struct PSL_CTRL** *\*P*, **double** *x0*,
  435. **double** *y0*, **double** *x1*, **double** *y1*)
  436. Creates a closed box with opposite corners at plot coordinates
  437. (*x0*,\ *y1*) and (*x1*,\ *y1*). The box may be filled and its
  438. outline stroked depending on the current settings for fill and pen
  439. attributes.
  440. **long PSL_plotpolygon** (**struct PSL_CTRL** *\*P*, **double** *x*,
  441. **double** *y*, **long** *n*)
  442. Creates a closed polygon through *n* points whose plot coordinates
  443. are in the *x*, *y* arrays. The polygon may be filled and its
  444. outline stroked depending on the current settings for fill and pen
  445. attributes.
  446. **long PSL_plotsegment** (**struct PSL_CTRL** *\*P*, **double** *x0*,
  447. **double** *y0*, **double** *x1*, **double** *y1*)
  448. Draws a line segment between the two points (plot coordinates) using
  449. the current pen attributes.
  450. Plotting Symbols
  451. ----------------
  452. Here are functions used to plot various geometric symbols or constructs.
  453. **long PSL_plotaxis** (**struct PSL_CTRL** *\*P*, **double**
  454. *tickval*, **char** *\*label*, **double** *fontsize*, **long** *side*)
  455. Plots a basic axis with tick marks, annotations, and label. Assumes
  456. that **PSL_beginaxes** has been called to set up positioning and
  457. user data ranges. Annotations will be set using the *fontsize* in
  458. points. *side* can be 0, 1, 2, or 3, which selects lower x-axis,
  459. right y-axis, upper x-axis, or left y-axis, respectively. The
  460. *label* font size is set to 1.5 times the *fontsize*.
  461. **long PSL_plotsymbol** (**struct PSL_CTRL** *\*P*, **double** *x*,
  462. **double** *y*, **double** *size*\ [], **long** *symbol*)
  463. Plots a simple geometric symbol centered on plot coordinates (*x*,
  464. *y*). The argument *symbol* selects the geometric symbol to use.
  465. Most symbols are scaled to fit inside a circle of diameter given as
  466. *size*\ [0], but some symbols take additional parameters. Choose
  467. from these 1-parameter symbols using the predefined self-explanatory
  468. integer values PSL_CIRCLE, PSL_DIAMOND, PSL_HEXAGON,
  469. PSL_INVTRIANGLE, PSL_OCTAGON, PSL_PENTAGON, PSL_SQUARE,
  470. PSL_STAR, and PSL_TRIANGLE; these may all be filled and stroked if
  471. **PSL_setfill** has been called first. In addition, you can choose
  472. several line-only symbols that cannot be filled. They are
  473. PSL_CROSS, PSL_DOT, PSL_PLUS, PSL_XDASH, and PSL_YDASH.
  474. Finally, more complicated symbols require more than one parameter to
  475. be passed via *size*. These are PSL_ELLIPSE (*size* is expected to
  476. contain the three parameter *angle*, *major*, and *minor* axes,
  477. which defines an ellipse with its major axis rotated by *angle*
  478. degrees), PSL_MANGLE (*size* is expected to contain the 10
  479. parameters *radius*, *angle1*, and *angle2* for the math angle
  480. specification, followed by *tailwidth*, *headlength*, *headwidth*,
  481. *shape*, *status*, *trim1* and *trim2* (see PSL_VECTOR below for explanation),
  482. PSL_WEDGE (*size* is expected to contain the three parameter
  483. *radius*, *angle1*, and *angle2* for the sector specification),
  484. PSL_RECT (*size* is expected to contain the two dimensions *width*
  485. and *height*), PSL_RNDRECT (*size* is expected to contain the two
  486. dimensions *width* and *height* and the *radius* of the corners),
  487. PSL_ROTRECT (*size* is expected to contain the three parameter
  488. *angle*, *width*, and *height*, with rotation relative to the
  489. horizontal), and PSL_VECTOR (*size* is expected to contain the 9
  490. parameters *x_tip*, *y_tip*, *tailwidth*, *headlength*,
  491. *headwidth*, *shape*, *status*, *head1*, *head2*, *trim1*, and *trim2*.
  492. Here (*x_tip*,\ *y_tip*) are
  493. the coordinates to the head of the vector, while (*x*, *y*) are
  494. those of the tail. *shape* can take on values from 0-1 and specifies
  495. how far the intersection point between the base of a straight vector
  496. head and the vector line is moved toward the tip. 0.0 gives a
  497. triangular head, 1.0 gives an arrow shaped head. The *status* value
  498. is a bit-flag being the sum of several possible contributions:
  499. PSL_VEC_RIGHT (2) = only draw right half
  500. of vector head, PSL_VEC_BEGIN (4) =
  501. place vector head at beginning of vector,
  502. PSL_VEC_END (8) = place vector head at end of vector,
  503. PSL_VEC_JUST_B (0) = align vector beginning at (x,y),
  504. PSL_VEC_JUST_C (16) = align vector center at (x,y),
  505. PSL_VEC_JUST_E (32) = align vector end at (x,y),
  506. PSL_VEC_JUST_S (64) = align vector center at (x,y),
  507. PSL_VEC_OUTLINE (128) = draw vector head outline using default
  508. pen, PSL_VEC_FILL (512) = fill vector head using default fill,
  509. PSL_VEC_MARC90 (2048) = if angles subtend 90, draw straight angle
  510. symbol (PSL_MANGLE only). The symbol may be filled and its outline
  511. stroked depending on the current settings for fill and pen
  512. attributes. The parameters *head1* and *head2* determines
  513. what kind of vector head will be plotted at the two ends (if selected).
  514. 0 = normal vector head, 1 = circle, 2 = terminal crossbar.
  515. Finally, *trim1* and *trim2* adjust the start and end location of
  516. the vector.
  517. Plotting Images
  518. ---------------
  519. Here are functions used to read and plot various images.
  520. **long PSL_plotbitimage** (**struct PSL_CTRL** *\*P*, **double** *x*,
  521. **double** *y*, **double** *xsize*, **double** *ysize*, **int**
  522. *justify*, **unsigned char** *buffer*, **long** *nx*, **long** *ny*,
  523. **double** *f_rgb*\ [], **double** *b_rgb*\ [])
  524. Plots a 1-bit image image at plot coordinates (*x*, *y*) justified
  525. as per the argument *justify* (see **JUSTIFICATION** for details).
  526. The target size of the image is given by *xsize* and *ysize* in user
  527. units. If one of these is specified as zero, the corresponding size
  528. is adjusted to the other such that the aspect ratio of the original
  529. image is retained. *buffer* is an unsigned character array in
  530. scanline orientation with 8 pixels per byte. *nx*, *ny* refers to
  531. the number of pixels in the image. The rowlength of *buffer* must be
  532. an integral number of 8; pad with zeros. *buffer*\ [0] is upper left
  533. corner. You may replace the foreground color (the set bits) with the
  534. *f_rgb* color and the background color (the unset bits) with
  535. *b_rgb*. Alternatively, pass either color with the red component
  536. set to -1.0 and we will instead issue an image mask that is
  537. see-through for the specified fore- or background component. See the
  538. Adobe Systems PostScript Reference Manual for more details.
  539. **long PSL_plotcolorimage** (**struct PSL_CTRL** *\*P*, **double**
  540. *x*, **double** *y*, **double** *xsize*, **double** *ysize*, **int**
  541. *justify*, **unsigned char** *\*buffer*, **long** *nx*, **long** *ny*,
  542. **long** *depth*)
  543. Plots a 1-, 2-, 4-, 8-, or 24-bit deep image at plot coordinates
  544. (*x*, *y*) justified as per the argument *justify* (see
  545. **JUSTIFICATION** for details). The target size of the image is
  546. given by *xsize* and *ysize* in user units. If one of these is
  547. specified as zero, the corresponding size is adjusted to the other
  548. such that the aspect ratio of the original image is retained. This
  549. functions sets up a call to the PostScript colorimage or image
  550. operators. The pixel values are stored in *buffer*, an unsigned
  551. character array in scanline orientation with gray shade or r/g/b
  552. values (0-255). *buffer*\ [0] is the upper left corner. *depth* is
  553. number of bits per pixel (24, 8, 4, 2, or 1). *nx*, *ny* refers to
  554. the number of pixels in image. The rowlength of *buffer* must be an
  555. integral number of 8/\ *Idepth*. E.g. if *depth* = 4, then
  556. *buffer*\ [j]/16 gives shade for pixel[2j-1] and *buffer*\ [j%16
  557. (mod 16) gives shade for pixel[2j]. When *-depth* is passed instead
  558. then "hardware" interpolation of the image is requested (this is
  559. implementation dependent). If *-nx* is passed with 8- (or 24-) bit
  560. images then the first one (or three) bytes of *buffer* holds the
  561. gray (or r/g/b) color for pixels that are to be masked out using the
  562. PS Level 3 Color Mask method. See the Adobe Systems PostScript
  563. Reference Manual for more details.
  564. **long PSL_plotepsimage** (**struct PSL_CTRL** *\*P*, **double** *x*,
  565. **double** *y*, **double** *xsize*, **double** *ysize*, **int**
  566. *justify*, **unsigned char** *\*buffer*, **long** *size*, **long** *nx*,
  567. **long** *ny*, **long** *ox*, **long** *oy*)
  568. Plots an Encapsulated PostScript (EPS) image at plot coordinates
  569. (*x*, *y*) justified as per the argument *justify* (see
  570. **JUSTIFICATION** for details). The target size of the image is
  571. given by *xsize* and *ysize* in user units. If one of these is
  572. specified as zero, the corresponding size is adjusted to the other
  573. such that the aspect ratio of the original image is retained. The
  574. EPS file is stored in *buffer* and has *size* bytes. This function
  575. simply includes the image in the PostScript output stream within
  576. an appropriate wrapper. Specify position of lower left corner and
  577. size of image. *nx*, *ny*, *ox*, *oy* refers to the width, height
  578. and origin (lower left corner) of the BoundingBox in points.
  579. **long PSL_loadeps** (**struct PSL_CTRL** *\*P*, **char** *\*file*,
  580. **struct imageinfo** *\*header*, **unsigned char** *\*\*image*)
  581. Reads the image contents of the EPS file given by the *file name*.
  582. The *header* is filled with dimensional information. If *image*
  583. is NULL we return just with header, otherwise we read and return
  584. the entire EPS content via *image*.
  585. Plotting Text
  586. -------------
  587. Here are functions used to read and plot text strings and paragraphs.
  588. This can be somewhat complicated since we rely on the PostScript
  589. interpreter to determine the exact dimensions of text items given the
  590. font chosen. For perfect alignment you may have to resort to calculate
  591. offsets explicitly using **long PSL_deftextdim**, **PSL_set_height**
  592. and others and issue calculations with **PSL_setcommand**.
  593. **long PSL_plottext** (**struct PSL_CTRL** *\*P*, **double** *x*,
  594. **double** *y*, **double** *fontsize*, **char** *\*text*, **double**
  595. *angle*, **long** *justify*, **long** *mode*)
  596. The *text* is plotted starting at plot coordinates (*x*, *y*) and
  597. will make an *angle* with the horizontal. The point (*x*, *y*) maps
  598. onto different points of the text-string by giving various values
  599. for *justify* (see **JUSTIFICATION** for details). If *justify* is
  600. negative, then all leading and trailing blanks are stripped before
  601. plotting. Certain character sequences (flags) have special meaning
  602. to **PSL_plottext**. @~ toggles between current font and the
  603. Mathematical Symbols font. @%\ *no*\ % selects font *no* while @%%
  604. resets to the previous font. @- turns subscript on/off, @+ turns
  605. superscript on/off, @# turns small caps on/off, and @\\ will make a
  606. composite character of the following two character. @;\ *r/g/b*;
  607. changes the font color while @;; resets it [optionally append
  608. =\ *transparency* to change the transparency (0--100) of the text
  609. (the Default is opaque or 0)], @:\ *size*: changes the font size
  610. (@:: resets it), and @\_ toggles underline on/off. If *text* is NULL
  611. then we assume **PSL_plottextbox** was called first. Give
  612. *fontsize* in points. Normally, the text is typed using solid
  613. characters in the current color (set by **PSL_setcolor**). To draw
  614. outlined characters, set *mode* == 1; the outline will get the
  615. current color and the text is filled with the current fill color
  616. (set by **PSL_setfill**). Use *mode* == 2 if the current fill is a
  617. pattern. Use *mode* == 3 to achieve the same as *mode* == 1, while
  618. preventing the outline from obsuring any filled text font; the outline
  619. will hence be reduced to half the selected width. If the text is not
  620. filled, *mode* == 3 operates the same as *mode* == 1.
  621. If *fontsize* is negative it means that the current point
  622. has already been set before **PSL_plottext** was called and that
  623. (*x*, *y*) should be ignored.
  624. **long PSL_plottextbox** (**struct PSL_CTRL** *\*P*, **double** *x*,
  625. **double** *y*, **double** *fontsize*, **char** *\*text*, **double**
  626. *angle*, **long** *justify*, **double** *offset*\ [], **long** *mode*)
  627. This function is used in conjugation with **PSL_plottext** when a
  628. box surrounding the text string is desired. Taking most of the
  629. arguments of **PSL_plottext**, the user must also specify *mode* to
  630. indicate whether the box needs rounded (PSL_YES = 1) or straight
  631. (PSL_NO = 0) corners. The box will be colored with the current fill
  632. style set by **PSL_setfill**. That means, if an outline is desired,
  633. and the color of the inside of the box should be set with that
  634. routine. The outline will be drawn with the current pen color (and
  635. width). The *offset* array holds the horizontal and vertical
  636. distance gaps between text and the surrounding text box in distance
  637. units. The smaller of the two determined the radius of the rounded
  638. corners (if requested).
  639. **long PSL_deftextdim** (**struct PSL_CTRL** *\*P*, **char**
  640. *\*prefix*, **double** *fontsize*, **char** *\*text*)
  641. Computes the dimensions (width and height) required by the selected
  642. *text* given the current font and its *fontsize* (in points). The
  643. values are stored as PostScript variables called *prefix*\ \_w and
  644. *prefix*\ \_h, respectively. This function can be used to compute
  645. dimensions and, via BF(PSL_setcommand), calculate chances to
  646. position a particular item should be plotted. For instance, if you
  647. compute a position this way and wish to plot the text there, pass
  648. the coordinates to **PSL_plottext** as NaNs. If *prefix* is BF(-w),
  649. BF(-h), BF(-d) or BF(-b), no PostScript variables will be
  650. assigned, but the values of width, height, depth, or both width and
  651. height will be left on the PostScript stack.
  652. **long PSL_setparagraph** (**struct PSL_CTRL** *\*P*, **double**
  653. *line_space*, **double** *par_width*, **long** *par_just*)
  654. Initialize common settings to be used when typesetting paragraphs of
  655. text with **PSL_plotparagraph**. Specify the line spacing (1 equals
  656. the font size) and paragraph width (in distance units). Text can be
  657. aligned left (PSL_BL), centered (PSL_BC), right (PSL_BR), or
  658. justified (PSL_JUST) and is controlled by *par_just*.
  659. **long PSL_plotparagraphbox** (**struct PSL_CTRL** *\*P*,
  660. **double** *x*, **double** *y*, **double** *fontsize*, **char**
  661. *\*text*, **double** *angle*, **long** *justify*, **double**
  662. *offset*\ [], **long** *mode*)
  663. Computes and plots the text rectangle for a paragraph using the
  664. specified *fontsize* (in points). Here, *text* is an array of
  665. the text to be typeset, using the settings initialized by
  666. **PSL_setparagraph**. The escape sequences described for
  667. **PSL_plottext** can be used to modify the text. Separate text
  668. into several paragraphs by appending \\r to the last item in a
  669. paragraph. The whole text block is positioned at plot
  670. coordinates *x*, *y*, which is mapped to a point on the block
  671. specified by *justify* (see **JUSTIFICATION** for details). The
  672. whole block is then shifted by the amounts *shift*\ []. The box
  673. will be plotted using the current fill and outline settings. The
  674. *offset* array holds the horizontal and vertical distance gaps
  675. between text and the surrounding text box in distance units. Use
  676. *mode* to indicate whether the box should be straight
  677. (PSL_RECT_STRAIGHT = 0), rounded (PSL_RECT_ROUNDED = 1),
  678. convex (PSL_RECT_CONVEX = 2) or concave (PSL_RECT_CONCAVE = 3).
  679. **long PSL_plotparagraph** (**struct PSL_CTRL** *\*P*, **double**
  680. *x*, **double** *y*, **double** *fontsize*, **char** *\*text*,
  681. **double** *angle*, **long** *justify*, **long** *mode*)
  682. Typesets paragraphs of text using the specified *fontsize* (in
  683. points). Here, *text* is an array of the text to be typeset,
  684. using the settings initialized by **PSL_setparagraph**. The
  685. escape sequences described for **PSL_plottext** can be used to
  686. modify the text. Separate text into several paragraphs by
  687. appending \\r to the last item in a paragraph. The whole text
  688. block is positioned at plot coordinates *x*, *y*, which is
  689. mapped to a point on the block specified by *justify* (see
  690. **JUSTIFICATION** for details). See **PSL_plotparagraphbox**
  691. for laying down the surrounding text rectangle first.
  692. **long PSL_plottextline** (**struct PSL_CTRL** *\*P*, **double**
  693. *\*xpath*, **double** *\*ypath*, **long** *\*np*, **long** *nseg*,
  694. **void** *\*arg1*\, **void** *\*arg2*\, **char** *\*text*\ [],
  695. **double** *angle*\ [], **long** *n_per_seg*\ [], **double** *fontsize,
  696. **long** *justify*, **double** *offset*\ [], **long** *mode*)
  697. Please text along one or more path segments. The function does
  698. different things depending on the bit flags in *mode*. A key
  699. distinction occurs if the bit flag contains the bit PSL_TXT_CURVED
  700. (64) which means we wish to typeset the text along a variable and curved
  701. baseline given by the segments in *xpath, ypath*; otherwise we set
  702. straight text (possibly at an angle) and the *xpath, ypath* are
  703. not considered for text placement [If no line drawing is desired
  704. then these two arrays may be NULL]. We will describe the action
  705. taken for each bit value. Multiple values may be passed at the
  706. same time and we processes from low to high bit.
  707. PSL_TXT_INIT: When mode contains this bit (1) we will initialize
  708. all the required variables and store them in the PostScript file.
  709. PSL_TXT_SHOW: We wish to see the text strings (otherwise they may
  710. only serve as guides to set up clip paths).
  711. PSL_TXT_CLIP_ON: Use the text and the paths to set up clip paths.
  712. PSL_TXT_DRAW: Draw the lines defined by the *xpath, ypath* arrays.
  713. PSL_TXT_CLIP_OFF: Turn the text path clipping off.
  714. We pass the text strings via *text*. The locations of text plotting
  715. depends on whether PSL_TXT_CURVED is selected. If it is then
  716. you must pass as *arg1* the *node* array indicating at which
  717. node in the *xpath, ypath* array the text will be plotted; let
  718. *arg2* be NULL. For
  719. straight baselines you must instead pass another set of x,y
  720. coordinates with the locations of the text label placements
  721. via *arg1, arg2*.
  722. Each label has its own entry in the
  723. *angle* array. The *text* is an array of text pointers to the
  724. individual text items. The
  725. *offset* array holds the x and y distance gaps between text and
  726. the surrounding text box in user units (the clip path is the
  727. combination of all these text boxes). Use *justify* to specify
  728. how the text string relates to the coordinates (see
  729. BF(JUSTIFICATION) for details).
  730. PSL_TXT_FILLBOX (128) will fill the text box (this requires you
  731. to first define the text box rgb color with **PSL_define_rgb**
  732. by setting a local PostScript variable that must be called PSL_setboxrgb).
  733. PSL_TXT_DRAWBOX (256) will draw the text box outlines (this requires
  734. you to first define the text box pen with **PSL_define_pen** by setting a local
  735. PostScript variable that must be called PSL_setboxpen). Before
  736. calling this function you must also initialize a PSL array for
  737. line pens and text fonts.
  738. Clipping
  739. --------
  740. Here are functions used to activate and deactivate clipping regions.
  741. **long PSL_beginclipping** (**struct PSL_CTRL** *\*P*, **double** *x*,
  742. **double** *y*, **long** *n*, **double** *rgb*\ [], **long** *flag*)
  743. Sets up a user-definable clip path as a series on *n* points with
  744. plot coordinates (*x*, *y*). Plotting outside this polygon will be
  745. clipped until **PSL_endclipping** is called. If *rgb*\ [0] = -1 the
  746. inside of the path is left empty, otherwise it is filled with the
  747. specified color. *flag* is used to create complex clip paths
  748. consisting of several disconnected regions, and takes on values 0-3.
  749. *flag* = PSL_PEN_MOVE_ABS (1) means
  750. this is the first path in a multisegment clip path. *flag* =
  751. PSL_PEN_DRAW_ABS (2) means this is
  752. the last segment. Thus, for a single path, *flag* =
  753. PSL_PEN_DRAW_AND_STROKE_ABS (3).
  754. **long PSL_endclipping** (**struct PSL_CTRL** *\*P*, **long** *mode*)
  755. Depending on the *mode* it restores the clip path. The *mode* values
  756. can be: -*n* will restore *n* levels of text-based clipping, *n*
  757. will restore *n* levels of polygon clipping, PSL_ALL_CLIP_TXT
  758. will undo all levels of text-based clipping, and PSL_ALL_CLIP_POL
  759. will undo all levels of polygon-based clipping.
  760. Miscellaneous Functions
  761. -----------------------
  762. Here are functions used to issue comments or to pass custom PostScript
  763. commands directly to the output PostScript file. In C these functions
  764. are declared as macros and they can accept a variable number of
  765. arguments. However, from FORTRAN only a single text argument may be
  766. passed.
  767. **long PSL_setcommand** (**struct PSL_CTRL** *\*P*, **char** *\*text*)
  768. Writes a raw PostScript command to the PostScript output file,
  769. e.g., "1 setlinejoin.
  770. **long PSL_comment** (**struct PSL_CTRL** *\*P*, **char** *\*text*)
  771. Writes a comment (*text*) to the PostScript output file, e.g.,
  772. "Start of graph 20. The comment are prefixed with with %% .
  773. Authors
  774. -------
  775. Paul Wessel, School of Ocean and Earth Science and Technology,
  776. `http://www.soest.hawaii.edu. <http://www.soest.hawaii.edu.>`_
  777. Remko Scharroo, EUMETSAT, Darmstadt, Germany,
  778. `http://www.eumetsat.int. <http://www.eumetsat.int.>`_
  779. Bugs
  780. ----
  781. Caveat Emptor: The authors are **not** responsible for any disasters,
  782. suicide attempts, or ulcers caused by correct **or** incorrect use of
  783. PSL. If you find bugs, please report them to the authors by
  784. electronic mail. Be sure to provide enough detail so that we can
  785. recreate the problem.
  786. See Also
  787. --------
  788. :doc:`psconvert`
  789. References
  790. ----------
  791. Adobe Systems Inc., 1990, PostScript language reference manual, 2nd
  792. edition, Addison-Wesley, (ISBN 0-201-18127-4).
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...