Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2793
| Newsgroups | comp.lang.postscript |
|---|---|
| From | Peter Billam <peter@www.pjb.com.au> |
| Subject | Re: How can I test for an open subpath ? |
| References | <slrnnrtfc1.51t.peter@box8.pjb.com.au> <npn0i9$fq5$1@dont-email.me> |
| Message-ID | <slrnns25ml.38i.peter@box8.pjb.com.au> (permalink) |
| Date | 2016-08-27 04:28 +0000 |
| Organization | Unlimited download news at news.astraweb.com |
On 2016-08-25, Carlos <angus@quovadis.com.ar> wrote:
> On 25/08/2016 11:42, Peter Billam wrote:
>> but I'd like to start a procedure with a lineto if there's
>> a currently open subpath, and with a moveto if there isn't.
>> Is there a neat way of doing this ?
>> Do I have to do forsenics inside pathforall ?
> It's actually quite simple using pathforall, since one of
> the procs it takes is called specifically on closepath.
> /isclosed {
> false
> { pop pop false exch pop }
> { pop pop false exch pop }
> { pop pop pop pop pop pop false exch pop }
> { true exch pop } pathforall
> } def
Yes, that's neat. For my use-case I changed the inital false to
true, so that with no current path it would return the same as
after a subpath has been closed, and then I took the liberty
of inverting all the booleans and renaming it is_open_subpath
/is_open_subpath { % Carlos comp.lang.postscript 20160826 inverted
false % except I treat no-currentpath the same as no-open-subpath
{ pop pop true exch pop }
{ pop pop true exch pop }
{ pop pop pop pop pop pop true exch pop }
{ false exch pop } pathforall
} bind def
in which form it appears in
http://www.pjb.com.au/comp/line_drawing.html#points2curve
http://www.pjb.com.au/comp/free/line_drawing.ps.txt
https://github.com/peterbillam/postscriptlib/blob/master/line_drawing.ps
and seems to work well :-) It seems sad to loop through the entire
path just in order to read the last item, but it's only once per
invocation. I'll roll it into other path-segment-constructor procs :-)
Thanks !
Peter
--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How can I test for an open subpath ? Peter Billam <peter@www.pjb.com.au> - 2016-08-25 09:42 +0000
Re: How can I test for an open subpath ? Carlos <angus@quovadis.com.ar> - 2016-08-25 16:49 +0200
Re: How can I test for an open subpath ? Peter Billam <peter@www.pjb.com.au> - 2016-08-27 04:28 +0000
Re: How can I test for an open subpath ? jdaw1 <jdawiseman@gmail.com> - 2016-08-27 10:32 -0700
csiph-web