Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

translate/rotate combination

28 views
Skip to first unread message

Lord K.

unread,
Mar 22, 2013, 5:07:58 AM3/22/13
to
Hi, I can't handle my combination of translate/rotate in the right way :-(

I want to "run" several postscript files and print them at various place
on a huge poster.

I would like to define a function with parameters being: <file> <r> <x>
<y>
meaning: go to (x,y) on the page, and rotate the TOP-LEFT edge of the
content of <file> around this (x,y) location with an angle of <r>.

Bounding box of <file> is well-known and is the same for all files to be
used: 200x2834.64

Here is my code:


/mypart {
gsave
translate
rotate 0 -2834.64 translate
save
/showpage {} def
/setpagedevice /pop load def
0 0 translate
1 1 scale
exch run %(BBox of file is 200 x 2834.64)
restore
grestore
} bind def
(part_1.ps) 90 500 0 mypart
(part_2.ps) 0 2000 1000 mypart


But obviously it doesn't work at all. What is wrong? Regards.

luser- -droog

unread,
Mar 23, 2013, 2:44:34 AM3/23/13
to
I haven't looked too closely, but I think you're just doing it backwards. Translate first so the center of rotation is the origin (ie. "untranslate" the small image), then rotate, then translate to the desired position.

luser- -droog

unread,
Mar 23, 2013, 2:46:05 AM3/23/13
to
On Friday, March 22, 2013 4:07:58 AM UTC-5, Lord K. wrote:
BTW, that's a tight little procedure. You've been reading the Green Book, ain'tcha?

John Deubert

unread,
Mar 24, 2013, 10:30:42 AM3/24/13
to
How does your procedure fail? Does it provoke an error or simply
produce no pages (or wrong pages)?

There are a few other points to consider:

- You do a bare-naked save, which is likely to fail in this context.
The save operator puts a saveobject on the stack, which is very likely
going to be removed by the code that you are executing from the disk.
Better is to give the save object a name:

/mySave save def
...
...
mySave restore

- Note that 0 0 translate and 1 1 scale are effectively no-ops.

- As a bit more bulletproofing, you should probably clean up the
operand and dictionary stacks after each executed file. A reasonable
replacement for your procedure might be something like this:

/mypart {
/oldstate save def % Note this gives us a "free" gsave
translate
rotate 0 -2834.64 translate
/showpage {} def
/setpagedevice /pop load def
exch run %(BBox of file is 200 x 2834.64)
clear % Clear operand stack
cleardictstack % Clean up dict stack
oldstate restore
} bind def
(part_1.ps) 90 500 0 mypart
(part_2.ps) 0 2000 1000 mypart

Incidentally, I think your approach is fundamentally solid. You are
doing your translates & rotates correctly, as fare as I can see.

By the way, there are a couple of Acumen Journal articles you might
find useful:

Issue 4, March 2001 - Concatenating PostScript Files
Issue 36, Nov 2004 - Using EPS File in Handwritten Code

The Journal is free for the downloading at

www.acumentraining.com/acumenjournal.html

--
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
www.acumentraining.com/acumenjournal.html

Lord K.

unread,
Mar 25, 2013, 5:28:00 AM3/25/13
to
Le Fri, 22 Mar 2013 23:44:34 -0700, luser- -droog a écrit :
> I haven't looked too closely, but I think you're just doing it
> backwards. Translate first so the center of rotation is the origin (ie.
> "untranslate" the small image), then rotate, then translate to the
> desired position.

Thank you, I finally got it.
0 new messages