5 .\" Define the PSPIC macro.
7 .\" When used other than with -Tps, -Tdvi, -Thtml, or -Txhtml it draws a box
8 .\" around where the picture would go.
12 .\" .PSPIC [-L|-R|-C|-I <indent>] <file> [<width> [<height>]]
25 . HTML-DO-IMAGE \\$1 l
32 . HTML-DO-IMAGE \\$1 r
38 . nr ps-offset (m;\\$2)
40 . HTML-DO-IMAGE \\$1 i
43 . \" centered is the default
46 . HTML-DO-IMAGE \\$1 c
55 . if (\\n[llx] : \\n[lly] : \\n[urx] : \\n[ury]) \{\
56 . nr ps-wid (\\n[urx] - \\n[llx])
57 . nr ps-ht (\\n[ury] - \\n[lly])
58 . if (\\n[ps-wid] < 0) \
59 . nr ps-wid (-\\n[ps-wid])
60 . if (\\n[ps-ht] < 0) \
61 . nr ps-ht (-\\n[ps-ht])
63 . \" if we have a <width> parameter, use it as the final
64 . \" image width; otherwise we use the image's natural width
65 . \" or the current line length, whatever is smaller
67 . nr ps-deswid (i;\\$2)
69 . nr ps-deswid ((\\n[.l] - \\n[.i]) <? \\n[ps-wid]p)
71 . \" compute the final image height (with proper rounding),
72 . \" based on the image's aspect
73 . nr ps-desht (\\n[ps-deswid] * 1000 + (\\n[ps-wid] / 2) \
74 / \\n[ps-wid] * \\n[ps-ht] \
77 . \" if we have a <height> parameter, use it as the final
78 . \" image height in case it is smaller than the height
79 . \" value we have just computed
80 . if ((\\n[.$] >= 3) & (\\n[ps-desht] > (i;0\\$3))) \{\
81 . nr ps-desht (i;\\$3)
82 . \" recompute the final image width since we always
83 . \" keep the correct image aspect
84 . nr ps-deswid (\\n[ps-desht] * 1000 + (\\n[ps-ht] / 2) \
85 / \\n[ps-ht] * \\n[ps-wid] \
89 . \" reserve vertical space for image
90 . ne (\\n[ps-desht]u + 1v)
92 . \" compute image offset w.r.t. the current left margin
93 . if (\\n[ps-offset-mode] == 0) \
94 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid] / 2)
95 . if (\\n[ps-offset-mode] == 1) \
97 . if (\\n[ps-offset-mode] == 2) \
98 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid])
100 . ie '\*[.T]'dvi' \{\
101 . \" prepare values for \special{psfile=...} as needed by dvips
102 . ie (\\n[ps-wid]p == \\n[ps-deswid]) \{\
103 . ds ps-scale \" empty
104 . ds ps-hoffset hoffset=-\\n[llx]
105 . ds ps-voffset voffset=-\\n[lly]
108 . nr ps-scale (\\n[ps-deswid] * 100 / \\n[ps-wid]p)
109 . nr ps-hoffset (-\\n[llx] * \\n[ps-scale] / 100)
110 . nr ps-voffset (-\\n[lly] * \\n[ps-scale] / 100)
111 . ds ps-scale hscale=\\n[ps-scale] vscale=\\n[ps-scale]
112 . ds ps-hoffset hoffset=\\n[ps-hoffset]
113 . ds ps-voffset voffset=\\n[ps-voffset]
118 \X'psfile=\\$1 \\*[ps-hoffset] \\*[ps-voffset] \\*[ps-scale]'
122 . \" prepare values for grops; the `ps-invis' and `ps-endinvis' escapes
123 . \" are for groff's -X switch to provide a PS preview with xditview:
124 . \" it uses -Tps for formatting but xditview can't handle EPS files,
125 . \" thus alternative code is enclosed between those two escapes
126 . ds ps-invis \X'ps: invis'
127 . ds ps-endinvis \X'ps: endinvis'
128 . ds ps-import \X'ps: import \E$1 \En[llx] \En[lly] \En[urx] \En[ury] \
129 \En[ps-deswid] \E*[ps-desht]'
137 . ie (\\n[.$] >= 3) \
138 . ds ps-desht \\n[ps-desht]
140 . ds ps-desht \" empty
144 \# horizontally, the rectangle is slightly smaller than the image
145 \# to compensate the line thickness (especially needed for TTY devices)
146 \Z'\D'p 0 \\n[ps-desht]u \
147 (\\n[ps-deswid]u - \\n[.H]u) 0 \
149 \# for convenience we also display the image file name (centered vertically);
150 \Z'\v'((\\n[ps-desht]u / 2u) \
152 + ((\\n[rst]u + \\n[rsb]u) / 2u))'\h'1m'\\$1'\
166 .\" end of pspic.tmac