Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2576 > unrolled thread
| Started by | Andre Majorel <cheney@halliburton.com> |
|---|---|
| First post | 2016-05-20 16:28 +0000 |
| Last post | 2016-05-21 05:55 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.postscript
Saving currentpoint and CTM Andre Majorel <cheney@halliburton.com> - 2016-05-20 16:28 +0000
Re: Saving currentpoint and CTM luser- -droog <mijoryx@yahoo.com> - 2016-05-20 11:52 -0700
Re: Saving currentpoint and CTM luser- -droog <mijoryx@yahoo.com> - 2016-05-20 11:55 -0700
Re: Saving currentpoint and CTM Carlos <angus@quovadis.com.ar> - 2016-05-20 22:58 +0200
Re: Saving currentpoint and CTM Andre Majorel <cheney@halliburton.com> - 2016-05-21 17:52 +0000
Re: Saving currentpoint and CTM jdaw1 <jdawiseman@gmail.com> - 2016-05-21 05:55 -0700
| From | Andre Majorel <cheney@halliburton.com> |
|---|---|
| Date | 2016-05-20 16:28 +0000 |
| Subject | Saving currentpoint and CTM |
| Message-ID | <slrnnjueoi.4it.cheney@atc5.vermine.org> |
Is there a way to save (and later restore) currentpoint and the CTM, so that after restoring, you can resume adding to the path as if no moves or rotations had happened since you saved ? Rather not use gsave/grestore because 1. it saves and restores more things than I want, such as the path, 2. it is saved on the stack and I would prefer a dictionary of arrays or something like that which would give me the freedom of saving multiple times and restoring in any order without burdening my feeble brain. Thanks in advance. -- André Majorel http://www.teaser.fr/~amajorel/ J'ai des vrais problèmes, vous avez des faux problèmes.
[toc] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2016-05-20 11:52 -0700 |
| Message-ID | <9467b43b-2b45-40b3-899d-05201ebb7feb@googlegroups.com> |
| In reply to | #2576 |
On Friday, May 20, 2016 at 11:28:03 AM UTC-5, Andre Majorel wrote:
> Is there a way to save (and later restore) currentpoint and the
> CTM, so that after restoring, you can resume adding to the path
> as if no moves or rotations had happened since you saved ?
>
> Rather not use gsave/grestore because
> 1. it saves and restores more things than I want, such as the path,
> 2. it is saved on the stack and I would prefer a dictionary of
> arrays or something like that which would give me the freedom
> of saving multiple times and restoring in any order without
> burdening my feeble brain.
>
> Thanks in advance.
>
A couple of approaches you could look into.
You could use save/restore instead of gsave/grestore. These return
a 'save token' object and you can restore to any save-point by
using the appropriate token. In a sense you cannot restore "in any
order" because restoring to a lower save-point will invalidate
any higher-level tokens (if they're stored as definitions, then
the definitions should safely vanish upon restoring to the lower
level).
You could use user-paths. I don't fully understand how they work,
but they let you treat paths more like objects.
Create your own path objects. You can dump a path to a procedure
with something like:
[
{/moveto cvx}
{/lineto cvx}
{/curveto cvx}
{/closepath cvx}
pathforall ] cvx
To add a matrix, add something like
matrix currentmatrix /setmatrix cvx
after the first `[`. Then you can recreate the
same path by exec'ing this procedure.
[toc] | [prev] | [next] | [standalone]
| From | luser- -droog <mijoryx@yahoo.com> |
|---|---|
| Date | 2016-05-20 11:55 -0700 |
| Message-ID | <56ebb254-6765-4ca5-aea1-f18489d2b679@googlegroups.com> |
| In reply to | #2577 |
On Friday, May 20, 2016 at 1:52:50 PM UTC-5, luser- -droog wrote: > On Friday, May 20, 2016 at 11:28:03 AM UTC-5, Andre Majorel wrote: > > Is there a way to save (and later restore) currentpoint and the > > CTM, so that after restoring, you can resume adding to the path > > as if no moves or rotations had happened since you saved ? > > > > Rather not use gsave/grestore because > > 1. it saves and restores more things than I want, such as the path, > > 2. it is saved on the stack and I would prefer a dictionary of > > arrays or something like that which would give me the freedom > > of saving multiple times and restoring in any order without > > burdening my feeble brain. > > > > Thanks in advance. > > > > A couple of approaches you could look into. > > You could use save/restore instead of gsave/grestore. These return > a 'save token' object and you can restore to any save-point by > using the appropriate token. In a sense you cannot restore "in any > order" because restoring to a lower save-point will invalidate > any higher-level tokens (if they're stored as definitions, then > the definitions should safely vanish upon restoring to the lower > level). > This is probably even worse from the perspective of "saving more than I want". :(
[toc] | [prev] | [next] | [standalone]
| From | Carlos <angus@quovadis.com.ar> |
|---|---|
| Date | 2016-05-20 22:58 +0200 |
| Message-ID | <20160520225842.2a5f4a15@samara.DOMA> |
| In reply to | #2576 |
[Andre Majorel <cheney@halliburton.com>, 2016-05-20 16:28]
> Is there a way to save (and later restore) currentpoint and the
> CTM, so that after restoring, you can resume adding to the path
> as if no moves or rotations had happened since you saved ?
>
> Rather not use gsave/grestore because
> 1. it saves and restores more things than I want, such as the path,
> 2. it is saved on the stack and I would prefer a dictionary of
> arrays or something like that which would give me the freedom
> of saving multiple times and restoring in any order without
> burdening my feeble brain.
>
> Thanks in advance.
>
Do you mean something like this?
/savepos { [ currentpoint 6 array currentmatrix ] } def
/restorepos { aload pop setmatrix moveto } def
E.g.,
100 100 moveto 100 0 rlineto /x savepos def
0 20 260 { x restorepos rotate 50 0 rlineto } for
showpage
--
[toc] | [prev] | [next] | [standalone]
| From | Andre Majorel <cheney@halliburton.com> |
|---|---|
| Date | 2016-05-21 17:52 +0000 |
| Message-ID | <slrnnk182v.4it.cheney@atc5.vermine.org> |
| In reply to | #2579 |
On 2016-05-20, Carlos <angus@quovadis.com.ar> wrote:
> [Andre Majorel <cheney@halliburton.com>, 2016-05-20 16:28]
>> Is there a way to save (and later restore) currentpoint and the
>> CTM, so that after restoring, you can resume adding to the path
>> as if no moves or rotations had happened since you saved ?
>>
>> Rather not use gsave/grestore because
>> 1. it saves and restores more things than I want, such as the path,
>> 2. it is saved on the stack and I would prefer a dictionary of
>> arrays or something like that which would give me the freedom
>> of saving multiple times and restoring in any order without
>> burdening my feeble brain.
>
> Do you mean something like this?
>
> /savepos { [ currentpoint 6 array currentmatrix ] } def
> /restorepos { aload pop setmatrix moveto } def
>
> E.g.,
>
> 100 100 moveto 100 0 rlineto /x savepos def
> 0 20 260 { x restorepos rotate 50 0 rlineto } for
> showpage
With you making it so simple, I feel stupid for not working it
out myself.
Yes, that it exactly what I wanted. Thanks everyone.
--
André Majorel http://www.teaser.fr/~amajorel/
J'ai des vrais problèmes, vous avez des faux problèmes.
[toc] | [prev] | [next] | [standalone]
| From | jdaw1 <jdawiseman@gmail.com> |
|---|---|
| Date | 2016-05-21 05:55 -0700 |
| Message-ID | <37c32858-a6f1-488e-afe8-eedf5c7da079@googlegroups.com> |
| In reply to | #2576 |
Do you want to save the whole path, or just its end, the currentpoint? currentpoint matrix currentmatrix … % lots of stuff setmatrix newpath moveto
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web