2 .\"@ Define the PSPIC macro.
3 .\"@ When used other than with -Tps, -Tdvi, -Thtml, or -Txhtml it draws a box
4 .\"@ around where the picture would go.
6 .\"@ .PSPIC [-L|-R|-C|-I <indent>] [-N] <file> [<width> [<height>]]
8 .\" Adapted to S-roff by Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
21 . HTML-DO-IMAGE \\$1 l
28 . HTML-DO-IMAGE \\$1 r
34 . nr ps-offset (m;\\$2)
36 . HTML-DO-IMAGE \\$1 i
39 . \" centered is the default
42 . HTML-DO-IMAGE \\$1 c
46 . \" No vertical space
59 . if (\\n[llx] : \\n[lly] : \\n[urx] : \\n[ury]) \{\
60 . nr ps-wid (\\n[urx] - \\n[llx])
61 . nr ps-ht (\\n[ury] - \\n[lly])
62 . if (\\n[ps-wid] < 0) \
63 . nr ps-wid (-\\n[ps-wid])
64 . if (\\n[ps-ht] < 0) \
65 . nr ps-ht (-\\n[ps-ht])
67 . \" if we have a <width> parameter, use it as the final
68 . \" image width; otherwise we use the image's natural width
69 . \" or the current line length, whatever is smaller
71 . nr ps-deswid (i;\\$2)
73 . nr ps-deswid ((\\n[.l] - \\n[.i]) <? \\n[ps-wid]p)
75 . \" compute the final image height (with proper rounding),
76 . \" based on the image's aspect
77 . nr ps-desht (\\n[ps-deswid] * 1000 + (\\n[ps-wid] / 2) \
78 / \\n[ps-wid] * \\n[ps-ht] \
81 . \" if we have a <height> parameter, use it as the final
82 . \" image height in case it is smaller than the height
83 . \" value we have just computed
84 . if ((\\n[.$] >= 3) & (\\n[ps-desht] > (i;0\\$3))) \{\
85 . nr ps-desht (i;\\$3)
86 . \" recompute the final image width since we always
87 . \" keep the correct image aspect
88 . nr ps-deswid (\\n[ps-desht] * 1000 + (\\n[ps-ht] / 2) \
89 / \\n[ps-ht] * \\n[ps-wid] \
93 . \" reserve vertical space for image
94 . ne (\\n[ps-desht]u + \\n[ps-vspace]u)
96 . \" compute image offset w.r.t. the current left margin
97 . if (\\n[ps-offset-mode] == 0) \
98 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid] / 2)
99 . if (\\n[ps-offset-mode] == 1) \
101 . if (\\n[ps-offset-mode] == 2) \
102 . nr ps-offset (\\n[.l] - \\n[.i] - \\n[ps-deswid])
104 . ie '\*[.T]'dvi' \{\
105 . \" prepare values for \special{psfile=...} as needed by dvips
106 . ie (\\n[ps-wid]p == \\n[ps-deswid]) \{\
107 . ds ps-scale \" empty
108 . ds ps-hoffset hoffset=-\\n[llx]
109 . ds ps-voffset voffset=-\\n[lly]
112 . nr ps-scale (\\n[ps-deswid] * 100 / \\n[ps-wid]p)
113 . nr ps-hoffset (-\\n[llx] * \\n[ps-scale] / 100)
114 . nr ps-voffset (-\\n[lly] * \\n[ps-scale] / 100)
115 . ds ps-scale hscale=\\n[ps-scale] vscale=\\n[ps-scale]
116 . ds ps-hoffset hoffset=\\n[ps-hoffset]
117 . ds ps-voffset voffset=\\n[ps-voffset]
122 \X'psfile=\\$1 \\*[ps-hoffset] \\*[ps-voffset] \\*[ps-scale]'
126 . \" prepare values for grops; the `ps-invis' and `ps-endinvis' escapes
127 . \" are for groff's -X switch to provide a PS preview with xditview:
128 . \" it uses -Tps for formatting but xditview can't handle EPS files,
129 . \" thus alternative code is enclosed between those two escapes
130 . ds ps-invis \X'ps: invis'
131 . ds ps-endinvis \X'ps: endinvis'
132 . ds ps-import \X'ps: import \E$1 \En[llx] \En[lly] \En[urx] \En[ury] \
133 \En[ps-deswid] \E*[ps-desht]'
141 . ie (\\n[.$] >= 3) \
142 . ds ps-desht \\n[ps-desht]
144 . ds ps-desht \" empty
148 \# horizontally, the rectangle is slightly smaller than the image
149 \# to compensate the line thickness (especially needed for TTY devices)
150 \Z'\D'p 0 \\n[ps-desht]u \
151 (\\n[ps-deswid]u - \\n[.H]u) 0 \
153 \# for convenience we also display the image file name (centered vertically);
154 \Z'\v'((\\n[ps-desht]u / 2u) \
156 + ((\\n[rst]u + \\n[rsb]u) / 2u))'\h'1m'\\$1'\