[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Rotating an EPS file
From: |
Tadziu Hoffmann |
Subject: |
Re: [Groff] Rotating an EPS file |
Date: |
Tue, 17 Dec 2002 10:39:28 +0100 |
User-agent: |
Mutt/1.4i |
> What is the way to rotate an eps figure in groff?
> I want to print text in a table rotated by 90 degree. So, as I
> found no direct way in groff, I thought about first making an
> EPS file of the text in its normal way and including it as a
> rotated EPS.
>
> Is there any way to rotate an EPS file in groff or do I have
> to rely on some external tools - and if, what tools can I use?
I've had a similar problem, since I like to plot diagrams in
landscape mode so I can print the out by themselves, but when I
want to include the images in some text they then have to be
rotated.
"ps: import" does too little or too much, depending on your
point of view. It does too little by not having the option of
rotating the included figure. Therefore, you have to include
some PostScript code of your own to do this. But once you do
your own PostScript coding, "ps: import" has more functionality
than necessary, because you can do the scaling it does
"natively" yourself.
(Maybe "ps: import" or the new proposed "image" special
should be augmented to include this kind of transformation.)
Anyhow, here's the macro I currently use myself to include
pictures with rotation. (It's called PSpic to not conflict with
the official pspic.) It has three additional options "-l",
"-r", and "-u" for images rotated left or right 90 degrees or
upside-down. The only problem with this solution is lots of
warnings from grops stating that the top of the included figure
is above the top of the page, which it isn't, but grops doesn't
know because it can't tell that the graphics state was tweaked.
It's not a "clean" solution, because it still uses the builtin
scaling of "ps: import" at the expense of some abstruse
transformations of the coordinate system. Maybe when I have
some more time I can work out a prettier implementation.
.\" tmac.pspic
.\"
.\" defines the PSpic macro for importing PostScript graphics
.\" ================================================================
.de PSpic
.br
.nr ps-offset-mode 0
.nr ps-rotate-mode 0
.\" ----------------------------------------------------------------
.\" parse optional arguments
.if '\\$1'-L' \{\
.nr ps-offset-mode 1
.shift
.\}
.if '\\$1'-R' \{\
.nr ps-offset-mode 2
.shift
.\}
.if '\\$1'-I' \{\
.nr ps-offset-mode 3
.nr ps-offset (m;\\$2)
.shift 2
.\}
.if '\\$1'-l' \{\
.nr ps-rotate-mode 1
.shift
.\}
.if '\\$1'-r' \{\
.nr ps-rotate-mode 2
.shift
.\}
.if '\\$1'-u' \{\
.nr ps-rotate-mode 3
.shift
.\}
.\" ----------------------------------------------------------------
.\" get the bounding box and natural width and height of the graphic
.psbb \\$1
.if (\\n[llx] : \\n[lly] : \\n[urx] : \\n[ury]) \{\
.\" .tm postscript graphic "\\$1": \\n[llx] \\n[lly] \\n[urx] \\n[ury]
.nr ps-nat-wd (\\n[urx]-\\n[llx])
.nr ps-nat-ht (\\n[ury]-\\n[lly])
.if \\n[ps-nat-wd]<0 .nr ps-nat-wd 0-\\n[ps-nat-wd]
.if \\n[ps-nat-ht]<0 .nr ps-nat-ht 0-\\n[ps-nat-ht]
.\" ----------------------------------------------------------------
.\" for rotated graphics, exchange width and height
.if \\n[ps-rotate-mode]=0 \{\
.nr ps-rot-wd \\n[ps-nat-wd]
.nr ps-rot-ht \\n[ps-nat-ht]
.\}
.if \\n[ps-rotate-mode]=1 \{\
.nr ps-rot-wd \\n[ps-nat-ht]
.nr ps-rot-ht \\n[ps-nat-wd]
.\}
.if \\n[ps-rotate-mode]=2 \{\
.nr ps-rot-wd \\n[ps-nat-ht]
.nr ps-rot-ht \\n[ps-nat-wd]
.\}
.if \\n[ps-rotate-mode]=3 \{\
.nr ps-rot-wd \\n[ps-nat-wd]
.nr ps-rot-ht \\n[ps-nat-ht]
.\}
.\" ----------------------------------------------------------------
.\" calculate scaling factors from the (possibly rotated)
.\" graphics size and the requested size
.ie \\n[.$]>=2 .nr ps-req-wd (i;\\$2)
.el .nr ps-req-wd \\n[.l]-\\n[.i]
.nr ps-req-ht \\n[ps-req-wd]*\\n[ps-rot-ht]/\\n[ps-rot-wd]
.if \\n[.$]>=3&(\\n[ps-req-ht]>(i;0\\$3)) \{\
.nr ps-req-ht (i;\\$3)
.nr ps-req-wd \\n[ps-req-ht]*\\n[ps-rot-wd]/\\n[ps-rot-ht]
.\}
.if \\n[ps-offset-mode]=0 .nr ps-offset \\n[.l]-\\n[.i]-\\n[ps-req-wd]/2
.if \\n[ps-offset-mode]=1 .nr ps-offset 0
.if \\n[ps-offset-mode]=2 .nr ps-offset \\n[.l]-\\n[.i]-\\n[ps-req-wd]
.\" ----------------------------------------------------------------
.ne \\n[ps-req-ht]u+1v
.if \\n[ps-rotate-mode]=0 \
\h'\\n[ps-offset]u'\
\v'\\n[ps-req-ht]u-.3v'\
\X'ps: import \\$1 \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[ps-req-wd]'
.if \\n[ps-rotate-mode]=1 \
\h'\\n[ps-offset]u+\\n[ps-req-wd]u'\
\v'\\n[ps-req-ht]u-.3v'\
\X'ps: exec gsave currentpoint 2 copy translate -90 rotate \
neg exch neg exch translate'\
\X'ps: import \\$1 \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[ps-req-ht]'\
\X'ps: exec grestore'
.if \\n[ps-rotate-mode]=2 \
\h'\\n[ps-offset]u'\
\v'-.3v'\
\X'ps: exec gsave currentpoint 2 copy translate 90 rotate \
neg exch neg exch translate'\
\X'ps: import \\$1 \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[ps-req-ht]'\
\X'ps: exec grestore'
.if \\n[ps-rotate-mode]=3 \
\h'\\n[ps-offset]u+\\n[ps-req-wd]u'\
\v'-.3v'\
\X'ps: exec gsave currentpoint 2 copy translate 180 rotate \
neg exch neg exch translate'\
\X'ps: import \\$1 \\n[llx] \\n[lly] \\n[urx] \\n[ury] \\n[ps-req-wd]'\
\X'ps: exec grestore'
.sp \\n[ps-req-ht]u
.\}
..
.\" ================================================================