Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1334 > unrolled thread
| Started by | "Lord K." <kax@kax.org> |
|---|---|
| First post | 2013-03-22 09:07 +0000 |
| Last post | 2013-03-24 07:30 -0700 |
| Articles | 5 — 3 participants |
Back to article view | Back to comp.lang.postscript
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
| From | "Lord K." <kax@kax.org> |
|---|---|
| Date | 2013-03-22 09:07 +0000 |
| Subject | translate/rotate combination |
| Message-ID | <514c1f6e$0$21949$426a34cc@news.free.fr> |
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.
[toc] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-03-22 23:44 -0700 |
| Message-ID | <20e05cd7-c8ba-4f01-a6ce-01e46ab6abb4@googlegroups.com> |
| In reply to | #1334 |
On Friday, March 22, 2013 4:07:58 AM UTC-5, Lord K. wrote:
> 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.
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.
[toc] | [prev] | [next] | [standalone]
| From | "Lord K." <kax@kax.org> |
|---|---|
| Date | 2013-03-25 09:28 +0000 |
| Message-ID | <515018a0$0$1970$426a74cc@news.free.fr> |
| In reply to | #1336 |
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.
[toc] | [prev] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2013-03-22 23:46 -0700 |
| Message-ID | <1b58912b-e9ba-4bcf-a2eb-7bf93d072db3@googlegroups.com> |
| In reply to | #1334 |
On Friday, March 22, 2013 4:07:58 AM UTC-5, Lord K. wrote:
> 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.
BTW, that's a tight little procedure. You've been reading the Green Book, ain'tcha?
[toc] | [prev] | [next] | [standalone]
| From | John Deubert <john@acumentraining.com> |
|---|---|
| Date | 2013-03-24 07:30 -0700 |
| Message-ID | <2013032407304244013-john@acumentrainingcom> |
| In reply to | #1334 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web