Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1338
| From | John Deubert <john@acumentraining.com> |
|---|---|
| Organization | Acumen Training |
| Newsgroups | comp.lang.postscript |
| Date | 2013-03-24 07:30 -0700 |
| Message-ID | <2013032407304244013-john@acumentrainingcom> (permalink) |
| References | <514c1f6e$0$21949$426a34cc@news.free.fr> |
| Subject | Re: translate/rotate combination |
On 2013-03-22 09:07:58 +0000, Lord K. said:
> 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.
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
Back to comp.lang.postscript | Previous | Next — Previous in thread | Find similar | Unroll thread
translate/rotate combination "Lord K." <kax@kax.org> - 2013-03-22 09:07 +0000
Re: translate/rotate combination luser- -droog <mijoryx@yahoo.com> - 2013-03-22 23:44 -0700
Re: translate/rotate combination "Lord K." <kax@kax.org> - 2013-03-25 09:28 +0000
Re: translate/rotate combination luser- -droog <mijoryx@yahoo.com> - 2013-03-22 23:46 -0700
Re: translate/rotate combination John Deubert <john@acumentraining.com> - 2013-03-24 07:30 -0700
csiph-web