Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2509
| From | Carlos <angus@quovadis.com.ar> |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | Re: How long is a path? Alas currentdash is silent |
| Date | 2016-04-09 01:19 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <20160409011930.2181fb72@samara.DOMA> (permalink) |
| References | <7d687ea2-4b38-408d-be5f-e35d730137eb@googlegroups.com> <ne8a1s$7ud$1@dont-email.me> <6b1b15ac-2e3c-4eac-b4ce-6f57a39dfe30@googlegroups.com> |
[jdaw1 <jdawiseman@gmail.com>, 2016-04-08 14:32]
> I have never used 'instroke'. Cool.
>
> Would this work if the path was self-intersecting? And a path ending
> in 'closepath' is, in effect, self-intersecting.
You are right. It works for /pathlength, because we only have one big
black dash, and we are only interested on whether it started or not. It
doesn't matter which part of it touches the last point. What I
suggested in the last paragraph will probably fail with intersecting
paths.
By the way, I read about instroke and it is in fact device dependant,
so the imprecisions it shows are probably inside a device's pixel and
won't affect how the output looks. Maybe /pathlength is good enough for
your purposes after all.
BUT there was a bug in the code, and that was the reason why it didn't
work with a full circle, and why it doesn't work with closepath (I
didn't even notice that before).
I was setting the dash thus: [ 0 x x ] 0, and that 0-length black dash
at the beginning of the path was making instroke return true for the
first (= the last) point of the path.
Changing the dash settings to [ 1 x x ] 1 solves it.
Corrected code:
/pathlength {
0.0 % length so far
20 -1 -10 { %for
2 exch exp % dash length = 2^i
2 copy add % length so far + dash length
exch
gsave
2 setlinecap
% [ 1 lengthsofar+dashlength dashlength ] 1
1 index exch [ 1 4 2 roll ]
1 setdash
currentpoint instroke {
exch % lengthsofar <- lengthsofar+dashlength
} if
pop
grestore
} for
} bind def
--
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-05 16:34 -0700
Re: How long is a path? Alas currentdash is silent tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2016-04-05 21:45 -0400
Re: How long is a path? Alas currentdash is silent luser- -droog <mijoryx@yahoo.com> - 2016-04-05 19:09 -0700
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 01:26 -0700
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 05:07 -0700
Re: How long is a path? Alas currentdash is silent Scott Hemphill <hemphill@hemphills.net> - 2016-04-06 11:40 -0400
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 09:52 -0700
Re: How long is a path? Alas currentdash is silent sjprouty3765@gmail.com - 2016-04-06 12:05 -0700
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 14:55 -0700
Re: How long is a path? Alas currentdash is silent Scott Hemphill <hemphill@hemphills.net> - 2016-04-06 17:12 -0400
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 14:34 -0700
Re: How long is a path? Alas currentdash is silent Scott Hemphill <hemphill@hemphills.net> - 2016-04-06 11:35 -0400
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-06 09:38 -0700
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-07 01:39 -0700
Re: How long is a path? Alas currentdash is silent Carlos <angus@quovadis.com.ar> - 2016-04-08 15:04 +0200
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-08 14:32 -0700
Re: How long is a path? Alas currentdash is silent Carlos <angus@quovadis.com.ar> - 2016-04-09 01:19 +0200
Re: How long is a path? Alas currentdash is silent jdaw1 <jdawiseman@gmail.com> - 2016-04-08 14:57 -0700
Re: How long is a path? Alas currentdash is silent Carlos <angus@quovadis.com.ar> - 2016-04-09 01:31 +0200
csiph-web