Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #746

Re: setrgbcolor with lineto/curveto

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!panix!not-for-mail
From JohnF <john@please.see.sig.for.email.com>
Newsgroups comp.lang.postscript
Subject Re: setrgbcolor with lineto/curveto
Date Thu, 14 Jun 2012 04:11:56 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 80
Message-ID <jrboac$ips$2@reader1.panix.com> (permalink)
References <jra5b7$mqu$1@reader1.panix.com> <382344c9-0e46-42cc-9af3-8afd54b7a39c@b21g2000yqn.googlegroups.com> <c85e73cd-02ad-40b6-bae5-444c713debaa@e3g2000yqm.googlegroups.com> <3f425dd9-f3d7-4819-be2f-f5f6ddb7ba9c@f14g2000yqe.googlegroups.com>
NNTP-Posting-Host panix3.panix.com
X-Trace reader1.panix.com 1339647116 19260 166.84.1.3 (14 Jun 2012 04:11:56 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Thu, 14 Jun 2012 04:11:56 +0000 (UTC)
User-Agent tin/2.0.0-20110823 ("Ardenistiel") (UNIX) (NetBSD/5.1.2 (i386))
Xref csiph.com comp.lang.postscript:746

Show key headers only | View raw


luser- -droog <mijoryx@yahoo.com> wrote:
> On Jun 13, 7:16?pm, luser- -droog <mijo...@yahoo.com> wrote:
>> On Jun 13, 6:20?pm, luser- -droog <mijo...@yahoo.com> wrote:
>> > JohnF wrote:
>> > > Apologies if this is simple, but I don't know postscript
>> > > very well, and failed to google it...
>> > > I'd like to draw a lineto/curveto with the color varying
>> > > from one endpoint to the other. That is, it should start
>> > > with ?a b c setrgbcolor ?at one endpoint and end up with
>> > > a' b' c' setrgbcolor ?at the other end. It's decorative,
>> > > so a-->a', b-->b', c-->c' can vary linearly, or anything
>> > > like that, along the line's length. Thanks,
>>
>> > There is a trick you can do with curveto to chop it up
>> > into segments. You call 'flattenpath' and then use
>> > 'pathforall'. The 'lineto' callback will receive the coordinates
>> > of the segments, which you can then plot separately,
>> > making any desired adjustments to the graphics state
>> > as you go.
>>
>> > Flattenpath bisects the bezier curves until the deviation
>> > from a straight line is within the error threshold.
>> > So you adjust 'setflat' and 'currentflat' to control
>> > the chopping.
>>
>> > This may work with 'lineto's as well. I think gs will
>> > chop lines, but the PLRM is mum, so *caution*.
>> > Other interpreters might not. And I could be remembering wrong, too.
>>
>> Here's my attempt to do something similar:
>>
>> https://groups.google.com/group/comp.lang.postscript/
>> msg/7be550cfc43bebf4?hl=en
> 
> I do remember now that ghostscript works just fine with
> degenerate curves. So the "little wiggle" is wholy unnecessary.

Thanks, luser, that learn-by-example is very helpful indeed.
I'm reproducing it below just for immediate reference...

%!
%brush-change?

/lineto { 2 copy .02 add 2 copy .02 sub curveto } def

100 100 moveto
500 500 lineto

flattenpath
/p [
{/moveto cvx}
{/linet cvx}
{/curveto cvx}
{/closepath cvx}pathforall
] def

/m 10 1 0 p {
    dup type /nametype eq {
        /linet eq { 1 add } if
    }{ pop }ifelse

} forall div exp 1 matrix scale def

/a matrix def

/linet {
    lineto
    currentpoint
    matrix currentmatrix
    a setmatrix stroke
    /a a m matrix concatmatrix def
    setmatrix
    moveto

} def

p cvx exec

-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-13 13:41 +0000
  Re: setrgbcolor with lineto/curveto Helge Blischke <h.blischke@acm.org> - 2012-06-13 16:16 +0200
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-13 16:04 +0000
    Re: setrgbcolor with lineto/curveto Odysseus <odysseus1479-at@yahoo-dot.ca> - 2012-06-13 20:20 -0600
      Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-14 04:05 +0000
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-16 14:45 -0700
  Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 16:20 -0700
    Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 17:16 -0700
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-13 17:36 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-14 04:11 +0000
          Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-06-14 09:05 -0700
  Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 11:00 -0700
  Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 10:55 -0700
    Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-16 11:23 -0700
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-19 07:00 +0000
      Re: setrgbcolor with lineto/curveto gernot.hoffmann@hs-emden-leer.de - 2012-06-19 00:34 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-06-19 08:12 +0000
  Re: setrgbcolor with lineto/curveto John Deubert <john@acumentraining.com> - 2012-06-30 10:20 -0700
    Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-04 03:07 +0000
      Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-07-05 16:24 -0700
        Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-06 14:23 +0000
          Re: setrgbcolor with lineto/curveto JohnF <john@please.see.sig.for.email.com> - 2012-07-11 01:57 +0000
        Re: setrgbcolor with lineto/curveto tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-11 01:08 -0400
          Re: setrgbcolor with lineto/curveto luser- -droog <mijoryx@yahoo.com> - 2012-07-12 03:12 -0700
            Re: setrgbcolor with lineto/curveto tlvp <mPiOsUcB.EtLlLvEp@att.net> - 2012-07-12 22:20 -0400

csiph-web