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


Groups > comp.lang.postscript > #737 > unrolled thread

setrgbcolor with lineto/curveto

Started byJohnF <john@please.see.sig.for.email.com>
First post2012-06-13 13:41 +0000
Last post2012-07-12 22:20 -0400
Articles 20 on this page of 25 — 7 participants

Back to article view | Back to comp.lang.postscript


Contents

  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

Page 1 of 2  [1] 2  Next page →


#737 — setrgbcolor with lineto/curveto

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-13 13:41 +0000
Subjectsetrgbcolor with lineto/curveto
Message-ID<jra5b7$mqu$1@reader1.panix.com>
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,
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

[toc] | [next] | [standalone]


#738

FromHelge Blischke <h.blischke@acm.org>
Date2012-06-13 16:16 +0200
Message-ID<a3rlm7Fl6gU1@mid.individual.net>
In reply to#737
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,

You will have to (1) encapsulate your path to be drawn into gsave and 
grestore to prevent unwanted side effects and (2) define a shading pattern 
and then do the stroke.

For the details see the PLRM (Postscript Language Reference Manual).
Note that shading is a level3 feature.

Helge

[toc] | [prev] | [next] | [standalone]


#739

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-13 16:04 +0000
Message-ID<jradn6$ma$1@reader1.panix.com>
In reply to#738
Helge Blischke <h.blischke@acm.org> 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,
> 
> You will have to (1) encapsulate your path to be drawn into gsave and 
> grestore to prevent unwanted side effects and (2) define a shading pattern 
> and then do the stroke.
> 
> For the details see the PLRM (Postscript Language Reference Manual).
> Note that shading is a level3 feature.
> Helge

Thanks, Helge. Downloaded it from
  http://www.adobe.com/products/postscript/pdfs/PLRM.pdf
(after first mistakenly visiting the Promised Land Ranch
and Ministries at plrm.org:), and will proceed to figure
out your instructions. Thanks again,
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

[toc] | [prev] | [next] | [standalone]


#744

FromOdysseus <odysseus1479-at@yahoo-dot.ca>
Date2012-06-13 20:20 -0600
Message-ID<odysseus1479-at-8CE2C0.20202513062012@news.eternal-september.org>
In reply to#738
In article <a3rlm7Fl6gU1@mid.individual.net>,
 Helge Blischke <h.blischke@acm.org> 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,
> 
> You will have to (1) encapsulate your path to be drawn into gsave and 
> grestore to prevent unwanted side effects and (2) define a shading pattern 
> and then do the stroke.
> 
> For the details see the PLRM (Postscript Language Reference Manual).
> Note that shading is a level3 feature.

Another possibility, which doesn't need Level 3, is to use *strokepath* 
to convert the line to a closed path, and then *clip* to restrict 
subsequent painting operations to that region (e.g. a loop that paints a 
series of lines or rectangles in incrementally varying colours). It 
would be very easy to fill a straight line with a linear gradient this 
way, but making the graduations follow a curved path would be more 
complicated.

John, do you know in advance what the path will look like, or must the 
procedure work entirely from whatever arbitrary path is active when it's 
called? A general solution for the latter case will be much harder to 
develop.

-- 
Odysseus

[toc] | [prev] | [next] | [standalone]


#745

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-14 04:05 +0000
Message-ID<jrbntd$ips$1@reader1.panix.com>
In reply to#744
Odysseus <odysseus1479-at@yahoo-dot.ca> wrote:
> Helge Blischke <h.blischke@acm.org> 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,
>> 
>> You will have to (1) encapsulate your path to be drawn into gsave and 
>> grestore to prevent unwanted side effects and (2) define a shading pattern 
>> and then do the stroke.
>> 
>> For the details see the PLRM (Postscript Language Reference Manual).
>> Note that shading is a level3 feature.
> 
> Another possibility, which doesn't need Level 3, is to use *strokepath* 
> to convert the line to a closed path, and then *clip* to restrict 
> subsequent painting operations to that region (e.g. a loop that paints a 
> series of lines or rectangles in incrementally varying colours). It 
> would be very easy to fill a straight line with a linear gradient this 
> way, but making the graduations follow a curved path would be more 
> complicated.
> 
> John, do you know in advance what the path will look like, or must the 
> procedure work entirely from whatever arbitrary path is active when it's 
> called? A general solution for the latter case will be much harder to 
> develop.

Thanks, Odysseus (watch out for those pesky rocks!).
Known in advance, but drawing many lines.
It's all just decorative, see http://www.forkosh.com/lineart.html
for the application, and click the "download postscript" button
to get any example file you want. That file will have many explicit
move/line/curve-to's whose endpoints are calculated outside the file,
rather than a loop inside the file that "does the math".
I suppose inside-the-file-math would facilitate the color gradient
stuff, but that would be a non-trivial change to the existing code.

But any way you slice it, I see I'll have some not-quite-so-trivial
postscript to learn. I had just picked up the few trivial commands
illustrated in the file needed to do that pretty simple job.
   And those commands elicited some deja vu, vis-a-vis an HP pen
plotter I'd first used in the early 1970's to draw one or two of
those designs (after seeing them above a secretary's desk, who'd
fabricated them using string and pins). That pen plotter had
exactly the same moveto command, but also had penup and pendown
commands rather than lineto. I'm guessing HP evolved that kind
of early command set until it eventually became postscript.
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

[toc] | [prev] | [next] | [standalone]


#751

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-06-16 14:45 -0700
Message-ID<8f21d77c-38a9-4b93-9636-330caab43473@y41g2000yqm.googlegroups.com>
In reply to#744
On Jun 13, 9:20 pm, Odysseus <odysseus1479...@yahoo-dot.ca> wrote:
> In article <a3rlm7Fl6...@mid.individual.net>,
>  Helge Blischke <h.blisc...@acm.org> 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,
>
> > You will have to (1) encapsulate your path to be drawn into gsave and
> > grestore to prevent unwanted side effects and (2) define a shading pattern
> > and then do the stroke.
>
> > For the details see the PLRM (Postscript Language Reference Manual).
> > Note that shading is a level3 feature.
>
> Another possibility, which doesn't need Level 3, is to use *strokepath*
> to convert the line to a closed path, and then *clip* to restrict
> subsequent painting operations to that region (e.g. a loop that paints a
> series of lines or rectangles in incrementally varying colours). It
> would be very easy to fill a straight line with a linear gradient this
> way, but making the graduations follow a curved path would be more
> complicated.
>
> John, do you know in advance what the path will look like, or must the
> procedure work entirely from whatever arbitrary path is active when it's
> called? A general solution for the latter case will be much harder to
> develop.

I like this idea. I've been afraid of strokepath because it's one
of the rocks upon which my graphics library foundered. And it's
even undocumented in Cairo. There's something spooky and magical
about strokepath.

I've got some code here for the "loop that paints a series of
rectangles"
part:

http://stackoverflow.com/questions/7500185/postscript-drawing-a-gradient/7900346#7900346

[toc] | [prev] | [next] | [standalone]


#740

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-06-13 16:20 -0700
Message-ID<382344c9-0e46-42cc-9af3-8afd54b7a39c@b21g2000yqn.googlegroups.com>
In reply to#737

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.

[toc] | [prev] | [next] | [standalone]


#742

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-06-13 17:16 -0700
Message-ID<c85e73cd-02ad-40b6-bae5-444c713debaa@e3g2000yqm.googlegroups.com>
In reply to#740
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

[toc] | [prev] | [next] | [standalone]


#743

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-06-13 17:36 -0700
Message-ID<3f425dd9-f3d7-4819-be2f-f5f6ddb7ba9c@f14g2000yqe.googlegroups.com>
In reply to#742
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/7be550cfc43b...

I do remember now that ghostscript works just fine with
degenerate curves. So the "little wiggle" is wholy unnecessary.

[toc] | [prev] | [next] | [standalone]


#746

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-14 04:11 +0000
Message-ID<jrboac$ips$2@reader1.panix.com>
In reply to#743
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 )

[toc] | [prev] | [next] | [standalone]


#747

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-06-14 09:05 -0700
Message-ID<7f35b528-5134-4862-9859-ac55a334ef4f@f7g2000yqh.googlegroups.com>
In reply to#746
On Jun 13, 11:11 pm, JohnF <j...@please.see.sig.for.email.com> wrote:
> luser- -droog <mijo...@yahoo.com> wrote:

> >> 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...
>

Eek. Alright. Let make a few improvements and comments.

%!
%brush-change along a line-segment?

%not even necessary. gs rocks!
%/lineto { 2 copy  2 copy  curveto } def

100 100 moveto
500 500 lineto

flattenpath %chop curves and lines in the current path

/p [
{/moveto cvx} %each procedure creates a program sequence
{/linet cvx}  % on the stack which we then wrap in an array
{/curveto cvx} % which we can then 'cvx' to make a new procedure
{/closepath cvx}pathforall
] def

%create a scaling matrix
% x' = x * 10^(1/N), where N is the number of line segments
% y' = y
% so that gradually over the line,
% x increases from about 1 to 10.
/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 % a is the "working" matrix

%I'm not thrilled about creating and
% discarding 2 matrices on every segment
% but I'm too lazy to fix it right now.
/linet {
    lineto
    currentpoint
    matrix currentmatrix
    a setmatrix stroke
    /a a m matrix concatmatrix def
    setmatrix
    moveto
} def

% re-execute the path
% with our new specialized lineto
p cvx exec

[toc] | [prev] | [next] | [standalone]


#748

Fromgernot.hoffmann@hs-emden-leer.de
Date2012-06-16 11:00 -0700
Message-ID<4af5eb1e-4c3e-4586-bbc1-e833982dc80d@googlegroups.com>
In reply to#737
Posted once again.

Best regards --Gernot Hoffmann

----
%!PS-Adobe-3.0  EPSF-3.0
%%BoundingBox:  0 0 340 340
%%Creator:      Gernot Hoffmann
%%Title:        Color interpolation along Curve
%%CreationDate: June 15 / 2012

/mm {2.834646 mul} def	

% Bezier Reference:
% http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
% page 2

% 4 control points

/p0x 1.0 def
/p0y 0.0 def

/p1x 1.0 def
/p1y 0.5 def

/p2x 0.5 def
/p2y 1.0 def

/p3x 0.0 def
/p3y 1.0 def

% Start and end color

/R0 0.0 def
/G0 0.5 def
/B0 0.0 def

/R3 1.0 def
/G3 0.5 def
/B3 0.0 def

/Coeff % coefficients see Ref. page 2 
{
/ax p3x p2x 3 mul sub p1x 3 mul add p0x sub def 
/bx p2x 3 mul p1x 6 mul sub p0x 3 mul add def
/cx p1x 3 mul p0x 3 mul sub def

/ay p3y p2y 3 mul sub p1y 3 mul add p0y sub def
/by p2y 3 mul p1y 6 mul sub p0y 3 mul add def
/cy p1y 3 mul p0y 3 mul sub def
} def

/Ipol % color interpolation
{/R R3 R0 sub t mul R0 add def
 /G G3 G0 sub t mul G0 add def
 /B B3 B0 sub t mul B0 add def
 R G B setrgbcolor
} def  

/Func % function, using Bezier by Horner scheme
{
/x ax t mul bx add t mul cx add t mul p0x add def
/y ay t mul by add t mul cy add t mul p0y add def
} def

100 mm 100 mm scale

0.1 0.1 translate

% black lines

0.001 setlinewidth
0 0 moveto 1 0 lineto stroke
0 0 moveto 0 1 lineto stroke

% black curve

0.04 setlinewidth
p0x p0y moveto
p1x p1y p2x p2y p3x p3y curveto stroke 

% color curve

0.02 setlinewidth

/N 100 def % e.g. 100 subdivisions
/dt 1 N div def

Coeff

/t 0 def
Func
N
{ 
 Ipol 
/t t dt add def 
 x y moveto
 Func 
 x y lineto stroke
} repeat 

showpage 
----

[toc] | [prev] | [next] | [standalone]


#749

Fromgernot.hoffmann@hs-emden-leer.de
Date2012-06-16 10:55 -0700
Message-ID<e541e1bb-8ccd-4742-b96f-ab48ee60c0a7@googlegroups.com>
In reply to#737
Below a simple solution, using basic Bezier definitions.

http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
page 2

Best regards --Gernot Hoffmann

-----
%!PS-Adobe-3.0  EPSF-3.0
%%BoundingBox:  0 0 340 340
%%Creator:      Gernot Hoffmann
%%Title:        Color interpolation along Curve
%%CreationDate: June 15 / 2012

/mm {2.834646 mul} def	

% Bezier Reference:
% http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
% page 2

% 4 control points

/p0x 1.0 def
/p0y 0.0 def

/p1x 1.0 def
/p1y 0.5 def

/p2x 0.5 def
/p2y 1.0 def

/p3x 0.0 def
/p3y 1.0 def

% Start and end color

/R0 0.0 def
/G0 0.5 def
/B0 0.0 def

/R3 1.0 def
/G3 0.5 def
/B3 0.0 def

/Coeff % coefficients see Ref. page 2 
{
/ax p3x p2x 3 mul sub p1x 3 mul add p0x sub def 
/bx p2x 3 mul p1x 6 mul sub p0x 3 mul add def
/cx p1x 3 mul p0x 3 mul sub def

/ay p3y p2y 3 mul sub p1y 3 mul add p0y sub def
/by p2y 3 mul p1y 6 mul sub p0y 3 mul add def
/cy p1y 3 mul p0y 3 mul sub def
} def

/Ipol % color interpolation
{/R R3 R0 sub t mul R0 add def
 /G G3 G0 sub t mul G0 add def
 /B B3 B0 sub t mul B0 add def
 R G B setrgbcolor
} def  

/Func % function, using Bezier by Horner scheme
{
/x ax t mul bx add t mul cx add t mul p0x add def
/y ay t mul by add t mul cy add t mul p0y add def
} def

100 mm 100 mm scale

0.1 0.1 translate

% black lines

0.001 setlinewidth
0 0 moveto 1 0 lineto stroke
0 0 moveto 0 1 lineto stroke

% black curve

0.04 setlinewidth
p0x p0y moveto
p1x p1y p2x p2y p3x p3y curveto stroke 

% color curve

0.02 setlinewidth

/N 100 def % e.g. 100 subdivisions
/dt 1 N div def

Coeff

/t 0 def
Func
N
{ 
 Ipol 
/t t dt add def 
 x y moveto
 Func 
 x y lineto stroke
} repeat 

showpage 
-----

[toc] | [prev] | [next] | [standalone]


#750

Fromgernot.hoffmann@hs-emden-leer.de
Date2012-06-16 11:23 -0700
Message-ID<11af67f6-a20e-4e26-b8fa-0d93db4d0711@googlegroups.com>
In reply to#749
A correction:
----
/N 100 def % e.g. 100 subdivisions
/dt 1 N div def

Coeff

/t 0 def
Func
N
{ 
 Ipol
 x y moveto
/t t dt add def 
 Func 
 x y lineto stroke
} repeat 

showpage 
----

Best regards --Gernot Hoffmann

[toc] | [prev] | [next] | [standalone]


#752

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-19 07:00 +0000
Message-ID<jrp82q$m5o$1@reader1.panix.com>
In reply to#749
gernot.hoffmann@hs-emden-leer.de wrote:
> Below a simple solution, using basic Bezier definitions.
> 
> http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
> page 2
> 
> Best regards --Gernot Hoffmann

Thanks a lot for your help again, Prof. Hoffmann (I recall your
previous help in comp.graphics.algorithms, which was regarding
the same little decorative program www.forkosh.com/lineart.html
that I'm further modifying now).

I took your solution and simplified it a bit as illustrated below,
replacing bezier curves with straight lines so I could follow your
postscript ideas more easily. After that worked, I abstracted your
100-step loop into a function /Coline so that the program can draw
many lines,
  % X0,Y0=start point, X1,Y1=end point
  /X0 1.0 def   /Y0 0.0 def
  /X1 0.0 def   /Y1 1.0 def
  Coline
  /X0 0.0 def   /Y0 0.0 def
  /X1 1.0 def   /Y1 1.0 def
  Coline
So the example below just draws a big X. Ultimately, the program
will first generate your "stub" at top, followed by many, many,
many X0,Y0,X1,Y1 lines. Then I'll re-introduce your original /Func
(and /Coeff and control points) for bezier curveto's.
Thanks again, John (sig and email at bottom)
-----

%!PS-Adobe-3.0  EPSF-3.0
%%BoundingBox:  0 0 340 340
%%Creator:      Gernot Hoffmann
%%Title:        Color interpolation along line
%%CreationDate: June 15 / 2012

% Bezier Reference:
% http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
% page 2

% RGB0=Start color, RGB1=End color
/R0 0.0 def   /G0 0.5 def   /B0 0.0 def
/R1 1.0 def   /G1 0.5 def   /B1 0.0 def

% number of steps
/N 100 def % e.g. 100 subdivisions
/dt 1 N div def

/Ipol % color interpolation R = (R1-R0)*t + R0, similarly for G,B
{/r R1 R0 sub t mul R0 add def
 /g G1 G0 sub t mul G0 add def
 /b B1 B0 sub t mul B0 add def
 r g b setrgbcolor
} def  

/Func % straight line x = (X1-X0)*t + X0, similarly for y
{/x X1 X0 sub t mul X0 add def
 /y Y1 Y0 sub t mul Y0 add def
} def

/Coline % color line
{/t 0 def
 Func
 N
 { 
  Ipol
  x y moveto
  /t t dt add def 
  Func 
  x y lineto stroke
 } repeat 
} def

/mm {2.834646 mul} def	
100 mm 100 mm scale

0.1 0.1 translate

% black axis lines
0.001 setlinewidth
0 0 moveto 1 0 lineto stroke
0 0 moveto 0 1 lineto stroke

% color lines
0.01 setlinewidth

% X0,Y0=start point, X1,Y1=end point
/X0 1.0 def   /Y0 0.0 def
/X1 0.0 def   /Y1 1.0 def
Coline

% X0,Y0=start point, X1,Y1=end point
/X0 0.0 def   /Y0 0.0 def
/X1 1.0 def   /Y1 1.0 def
Coline

showpage 

-----

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

[toc] | [prev] | [next] | [standalone]


#753

Fromgernot.hoffmann@hs-emden-leer.de
Date2012-06-19 00:34 -0700
Message-ID<abf9fc36-51db-4d7f-9531-e5bd7b23f0e5@googlegroups.com>
In reply to#752
On Tuesday, June 19, 2012 9:00:42 AM UTC+2, JohnF wrote:
> gernot hoffmann wrote:
> > Below a simple solution, using basic Bezier definitions.
> > 
> > http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
> > page 2
> > 
> > Best regards --Gernot Hoffmann
> 
> Thanks a lot for your help again, Prof. Hoffmann (I recall your
> previous help in comp.graphics.algorithms, which was regarding
> the same little decorative program www.forkosh.com/lineart.html
> that I'm further modifying now).
> 
> I took your solution and simplified it a bit as illustrated below,
> replacing bezier curves with straight lines so I could follow your
> postscript ideas more easily. After that worked, I abstracted your
> 100-step loop into a function /Coline so that the program can draw
> many lines,
>   % X0,Y0=start point, X1,Y1=end point
>   /X0 1.0 def   /Y0 0.0 def
>   /X1 0.0 def   /Y1 1.0 def
>   Coline
>   /X0 0.0 def   /Y0 0.0 def
>   /X1 1.0 def   /Y1 1.0 def
>   Coline
> So the example below just draws a big X. Ultimately, the program
> will first generate your "stub" at top, followed by many, many,
> many X0,Y0,X1,Y1 lines. Then I'll re-introduce your original /Func
> (and /Coeff and control points) for bezier curveto's.
> Thanks again, John (sig and email at bottom)
> -----
> 
> %!PS-Adobe-3.0  EPSF-3.0
> %%BoundingBox:  0 0 340 340
> %%Creator:      Gernot Hoffmann
> %%Title:        Color interpolation along line
> %%CreationDate: June 15 / 2012
> 
> % Bezier Reference:
> % http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
> % page 2
> 
> % RGB0=Start color, RGB1=End color
> /R0 0.0 def   /G0 0.5 def   /B0 0.0 def
> /R1 1.0 def   /G1 0.5 def   /B1 0.0 def
> 
> % number of steps
> /N 100 def % e.g. 100 subdivisions
> /dt 1 N div def
> 
> /Ipol % color interpolation R = (R1-R0)*t + R0, similarly for G,B
> {/r R1 R0 sub t mul R0 add def
>  /g G1 G0 sub t mul G0 add def
>  /b B1 B0 sub t mul B0 add def
>  r g b setrgbcolor
> } def  
> 
> /Func % straight line x = (X1-X0)*t + X0, similarly for y
> {/x X1 X0 sub t mul X0 add def
>  /y Y1 Y0 sub t mul Y0 add def
> } def
> 
> /Coline % color line
> {/t 0 def
>  Func
>  N
>  { 
>   Ipol
>   x y moveto
>   /t t dt add def 
>   Func 
>   x y lineto stroke
>  } repeat 
> } def
> 
> /mm {2.834646 mul} def	
> 100 mm 100 mm scale
> 
> 0.1 0.1 translate
> 
> % black axis lines
> 0.001 setlinewidth
> 0 0 moveto 1 0 lineto stroke
> 0 0 moveto 0 1 lineto stroke
> 
> % color lines
> 0.01 setlinewidth
> 
> % X0,Y0=start point, X1,Y1=end point
> /X0 1.0 def   /Y0 0.0 def
> /X1 0.0 def   /Y1 1.0 def
> Coline
> 
> % X0,Y0=start point, X1,Y1=end point
> /X0 0.0 def   /Y0 0.0 def
> /X1 1.0 def   /Y1 1.0 def
> Coline
> 
> showpage 
> 
> -----
> 
> -- 
> John Forkosh

John,

thanks for the feedback. Feel free to modify anything.

My programming style ignores widely special PostScript
features, because it is based on named variables instead
of immediate stack operations. This improves understanda-
bility for non-PS-experts...

Best regards --Gernot Hoffmann

[toc] | [prev] | [next] | [standalone]


#754

FromJohnF <john@please.see.sig.for.email.com>
Date2012-06-19 08:12 +0000
Message-ID<jrpc8q$o1h$1@reader1.panix.com>
In reply to#753
gernot.hoffmann@hs-emden-leer.de wrote:
> JohnF wrote:
>> gernot hoffmann wrote:
>> > Below a simple solution, using basic Bezier definitions.
>> > 
>> > http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
>> > page 2
>> > 
>> > Best regards --Gernot Hoffmann
>> 
>> Thanks a lot for your help again, Prof. Hoffmann (I recall your
>> previous help in comp.graphics.algorithms, which was regarding
>> the same little decorative program www.forkosh.com/lineart.html
>> that I'm further modifying now).
>> 
>> I took your solution and simplified it a bit as illustrated below,
>> replacing bezier curves with straight lines so I could follow your
>> postscript ideas more easily. After that worked, I abstracted your
>> 100-step loop into a function /Coline so that the program can draw
>> many lines,
>>   % X0,Y0=start point, X1,Y1=end point
>>   /X0 1.0 def   /Y0 0.0 def
>>   /X1 0.0 def   /Y1 1.0 def
>>   Coline
>>   /X0 0.0 def   /Y0 0.0 def
>>   /X1 1.0 def   /Y1 1.0 def
>>   Coline
>> So the example below just draws a big X. Ultimately, the program
>> will first generate your "stub" at top, followed by many, many,
>> many X0,Y0,X1,Y1 lines. Then I'll re-introduce your original /Func
>> (and /Coeff and control points) for bezier curveto's.
>> Thanks again, John (sig and email at bottom)
>> -----
>> 
>> %!PS-Adobe-3.0  EPSF-3.0
>> %%BoundingBox:  0 0 340 340
>> %%Creator:      Gernot Hoffmann
>> %%Title:        Color interpolation along line
>> %%CreationDate: June 15 / 2012
>> 
>> % Bezier Reference:
>> % http://www.fho-emden.de/~hoffmann/bezier18122002.pdf
>> % page 2
>> 
>> % RGB0=Start color, RGB1=End color
>> /R0 0.0 def   /G0 0.5 def   /B0 0.0 def
>> /R1 1.0 def   /G1 0.5 def   /B1 0.0 def
>> 
>> % number of steps
>> /N 100 def % e.g. 100 subdivisions
>> /dt 1 N div def
>> 
>> /Ipol % color interpolation R = (R1-R0)*t + R0, similarly for G,B
>> {/r R1 R0 sub t mul R0 add def
>>  /g G1 G0 sub t mul G0 add def
>>  /b B1 B0 sub t mul B0 add def
>>  r g b setrgbcolor
>> } def  
>> 
>> /Func % straight line x = (X1-X0)*t + X0, similarly for y
>> {/x X1 X0 sub t mul X0 add def
>>  /y Y1 Y0 sub t mul Y0 add def
>> } def
>> 
>> /Coline % color line
>> {/t 0 def
>>  Func
>>  N
>>  { 
>>   Ipol
>>   x y moveto
>>   /t t dt add def 
>>   Func 
>>   x y lineto stroke
>>  } repeat 
>> } def
>> 
>> /mm {2.834646 mul} def        
>> 100 mm 100 mm scale
>> 
>> 0.1 0.1 translate
>> 
>> % black axis lines
>> 0.001 setlinewidth
>> 0 0 moveto 1 0 lineto stroke
>> 0 0 moveto 0 1 lineto stroke
>> 
>> % color lines
>> 0.01 setlinewidth
>> 
>> % X0,Y0=start point, X1,Y1=end point
>> /X0 1.0 def   /Y0 0.0 def
>> /X1 0.0 def   /Y1 1.0 def
>> Coline
>> 
>> % X0,Y0=start point, X1,Y1=end point
>> /X0 0.0 def   /Y0 0.0 def
>> /X1 1.0 def   /Y1 1.0 def
>> Coline
>> 
>> showpage 
>> 
>> -----
> 
> John,
> thanks for the feedback. Feel free to modify anything.
> 
> My programming style ignores widely special PostScript
> features, because it is based on named variables instead
> of immediate stack operations. This improves understanda-
> bility for non-PS-experts...
> 
> Best regards --Gernot Hoffmann

Yes, you definitely succeeded improving understandability.
I have a vanishingly small knowledge of postscript (and that's
approaching zero from the negative side), but your style allowed
me to pretty easily guess what to do in order to get what I wanted.
(The PLRM's so long and wordy that I pretty much put it aside
 on my ever-growing "to do" list. I also came across the shorter
    http://www-cdf.fnal.gov/offline/PostScript/BLUEBOOK.PDF
 but that's still pretty long, too.)

And, as I think you were hinting, I realize this should probably
be rewritten to use the stack like
   0.0 0.0 1.0 1.0 Coline
rather than using your more instructive named variables like
   /X0 0.0 def   /Y0 0.0 def
   /X1 1.0 def   /Y1 1.0 def
   Coline
which I'll probably get around to doing before changing
the C program that will actually use this stuff.

And I also especially like your
   /mm {2.834646 mul} def        
   100 mm 100 mm scale
notation, making the conversion just look like units following
the number. Thanks again,
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )

[toc] | [prev] | [next] | [standalone]


#772

FromJohn Deubert <john@acumentraining.com>
Date2012-06-30 10:20 -0700
Message-ID<2012063010205688771-john@acumentrainingcom>
In reply to#737
Just for the record, here's a smooth shading (partial) solution. It's 
smaller and cleaner (I think), but does require a Level 3 interpreter. 
Also, this produces the desired results only if you are stroking a 
single line segment or not-very-curvy bezier; it won’t fail with a more 
complex path, but will probably not give the results you want. A final 
solution would require some surgery on the code.

% ============== cut here ===========
/ShadingDict		<<			% This dict defines the gradient.
	/ShadingType 2			% We'll use a linear gradient...
	/ColorSpace [ /DeviceRGB ]	% ...in RGB
	/Coords [ 200 200 400 400 ] 	% These are the same as line segment endpoints
	/Domain [ 0 1 ]			% Internal parameter
	/Function	<<			% This defines how the color should vary...
		/FunctionType 2		% ...across the line
		/Domain [ 0 1 ]
		/Range [ 0 1 0 1 0 1 ]	% R, G, & B each can vary from 0 to 1
		/C0	[ 1 0 0 ]		% Start Color
		/C1	[ 0 1 0 ]		% End Color
		/N	1			% Varies linearly
	>>
>> def

3 setlinewidth				% Construct our path
200 200 moveto 400 400 lineto
strokepath clip				% Turn it into a clipping region
ShadingDict shfill				% Fill it with out gradient; Bob's your uncle!

showpage
% ============== cut here ===========


As long as I’m messing about with this (and what do *you* do on a 
Saturday morning?) here’s the same technique turned into a procedure 
named strokegradientline:

% ============== cut here ===========
/ShadingDict		<<			% Same ShadingDict as earlier.
	/ShadingType 2
	/ColorSpace [ /DeviceRGB ]
	/Coords [ 200 200 400 400 ]
	/Domain [ 0 1 ]
	/Function	<<
		/FunctionType 2	
		/Domain [ 0 1 ]
		/Range [ 0 1 0 1 0 1 ]
		/C0	[ 1 0 0 ]
		/C1	[ 0 1 0 ]
		/N	1
	>>
>> def


/strokegradientline	% [ r0 g0 b0 ] [ r1 g1 b1 ]  x0 y0 x1 y1  => ---
{
	gsave
	4 copy moveto lineto		% first let's the line
	strokepath clip				% and turn it into a clipping path
	ShadingDict begin			% Go get our Shading dictionary
	4 array astore				% Put the xy's into an array
	/Coords exch def			% And use it for the Coords entry
	Function begin				% Get the function dictionary
	/C1 exch def				% Put our colors into it as C0 and C1
	/C2 exch def
	end end						% Clean up the dict stack
	ShadingDict shfill			% And shfill it.
	grestore					% Restore our clipping path
} bind def

% And now try this puppy out
3 setlinewidth
[ 1 0 0 ][ 0 0 1 ] 200 200 400 400 strokegradientline
[ 0 1 1 ][ 1 1 0 ] 300 200 500 400 strokegradientline

showpage
% ============== cut here ===========

Again, this isn't a final solution to the problem of an arbitrary path, 
but I thought a
Smooth Shading example was called for.

If you’re curious about Smooth Shading, I wrote an article on the 
subject for my Acumen  Journal ages ago (let’s look that up...ah. 
November 2000; issue 1, actually). You can get it 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
acumentraining.com/acumenjournal.html

[toc] | [prev] | [next] | [standalone]


#778

FromJohnF <john@please.see.sig.for.email.com>
Date2012-07-04 03:07 +0000
Message-ID<jt0c0p$65q$1@reader1.panix.com>
In reply to#772
John Deubert <john@acumentraining.com> wrote:
> Just for the record, here's a smooth shading (partial) solution. It's 
> smaller and cleaner (I think), but does require a Level 3 interpreter. 
> Also, this produces the desired results only if you are stroking a 
> single line segment or not-very-curvy bezier; it won't fail with a more 
> complex path, but will probably not give the results you want. A final 
> solution would require some surgery on the code.

Thanks for the solution below, John. Who'd have thought there'd be
an www.acumentraining.com with an www.acumentraining.com/acumenjournal.html
for postscript (and pdf) training classes (and consulting)?
   I've already incorporated Prof. Hoffmann's previous solution into
the C program generating the ps designs, and some sample output
is at  http://www.forkosh.com/decorative1.ps  with those procedures
at the top. Note that I also took the opportunity to use Prof. Hoffmann's
"s=s+ds, 0<=s<=1" loop to vary the linewidth from one endpoint to the other,
so lines can optionally (user's choice) look like (elongated) wedges.
   But I'm definitely saving and will be studying your code, too (who,
exactly, is Bob, by the way?). Looks like it will require a bit more
side-by-side reading along with the plrm or bluebook, though I'm
already seeing your additional techniques for handling arguments
beyond /arg exch def. And, while I'd (very) briefly read about arrays and
dictionaries, I hadn't seen any examples (beyond those in the bluebook)
I was actually interested in. So it's already very instructive.
Thanks a lot.

> % ============== cut here ===========
> /ShadingDict            <<          % This dict defines the gradient.
>        /ShadingType 2               % We'll use a linear gradient...
>        /ColorSpace [ /DeviceRGB ]   % ...in RGB
>        /Coords [ 200 200 400 400 ]  % These are the same as line seg endpts
>        /Domain [ 0 1 ]              % Internal parameter
>        /Function       <<           % This defines how the color should...
>                /FunctionType 2      % ...vary across the line
>                /Domain [ 0 1 ]
>                /Range [ 0 1 0 1 0 1 ]  % R, G, & B each can vary from 0 to 1
>                /C0     [ 1 0 0 ]    % Start Color
>                /C1     [ 0 1 0 ]    % End Color
>                /N      1            % Varies linearly
>        >>
>>> def
> 
> 3 setlinewidth                      % Construct our path
> 200 200 moveto 400 400 lineto
> strokepath clip                     % Turn it into a clipping region
> ShadingDict shfill            % Fill it with out gradient; Bob's your uncle!
> 
> showpage
> % ============== cut here ===========
> 
> 
> As long as I'm messing about with this (and what do *you* do on a 
> Saturday morning?) here's the same technique turned into a procedure 
> named strokegradientline:
> 
> % ============== cut here ===========
> /ShadingDict            <<           % Same ShadingDict as earlier.
>        /ShadingType 2
>        /ColorSpace [ /DeviceRGB ]
>        /Coords [ 200 200 400 400 ]
>        /Domain [ 0 1 ]
>        /Function       <<
>                /FunctionType 2 
>                /Domain [ 0 1 ]
>                /Range [ 0 1 0 1 0 1 ]
>                /C0     [ 1 0 0 ]
>                /C1     [ 0 1 0 ]
>                /N      1
>        >>
>>> def
> 
> 
> /strokegradientline     % [ r0 g0 b0 ] [ r1 g1 b1 ]  x0 y0 x1 y1  => ---
> {
>        gsave
>        4 copy moveto lineto          % first let's the line
>        strokepath clip               % and turn it into a clipping path
>        ShadingDict begin             % Go get our Shading dictionary
>        4 array astore                % Put the xy's into an array
>        /Coords exch def              % And use it for the Coords entry
>        Function begin                % Get the function dictionary
>        /C1 exch def                  % Put our colors into it as C0 and C1
>        /C2 exch def
>        end end                       % Clean up the dict stack
>        ShadingDict shfill            % And shfill it.
>        grestore                      % Restore our clipping path
> } bind def
> 
> % And now try this puppy out
> 3 setlinewidth
> [ 1 0 0 ][ 0 0 1 ] 200 200 400 400 strokegradientline
> [ 0 1 1 ][ 1 1 0 ] 300 200 500 400 strokegradientline
> 
> showpage
> % ============== cut here ===========
> 
> Again, this isn't a final solution to the problem of an arbitrary path, 
> but I thought a
> Smooth Shading example was called for.
> 
> If you're curious about Smooth Shading, I wrote an article on the 
> subject for my Acumen  Journal ages ago (let's look that up...ah. 
> November 2000; issue 1, actually). You can get it free for the 
> downloading at www.acumentraining.com/acumenjournal.html.

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

[toc] | [prev] | [next] | [standalone]


#781

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-07-05 16:24 -0700
Message-ID<aa618404-b321-4635-b5d6-db52ce4daffd@l32g2000yqc.googlegroups.com>
In reply to#778
On Jul 3, 10:07 pm, JohnF <j...@please.see.sig.for.email.com> wrote:
> John Deubert <j...@acumentraining.com> wrote:
> > Just for the record, here's a smooth shading (partial) solution. It's
> > smaller and cleaner (I think), but does require a Level 3 interpreter.
> > Also, this produces the desired results only if you are stroking a
> > single line segment or not-very-curvy bezier; it won't fail with a more
> > complex path, but will probably not give the results you want. A final
> > solution would require some surgery on the code.
>
> Thanks for the solution below, John. Who'd have thought there'd be
> anwww.acumentraining.comwith anwww.acumentraining.com/acumenjournal.html
> for postscript (and pdf) training classes (and consulting)?
>    I've already incorporated Prof. Hoffmann's previous solution into
> the C program generating the ps designs, and some sample output
> is at  http://www.forkosh.com/decorative1.ps with those procedures
> at the top. Note that I also took the opportunity to use Prof. Hoffmann's
> "s=s+ds, 0<=s<=1" loop to vary the linewidth from one endpoint to the other,
> so lines can optionally (user's choice) look like (elongated) wedges.
>    But I'm definitely saving and will be studying your code, too (who,
> exactly, is Bob, by the way?). Looks like it will require a bit more
> side-by-side reading along with the plrm or bluebook, though I'm
> already seeing your additional techniques for handling arguments
> beyond /arg exch def. And, while I'd (very) briefly read about arrays and
> dictionaries, I hadn't seen any examples (beyond those in the bluebook)
> I was actually interested in. So it's already very instructive.
> Thanks a lot.
>

Don't forget the Green book! And 'Thinking in Postscript'
(the would've-been 'white book'). Both free online and super-cheap
used.
These are much more chatty and explanatory of how to use
Postscript effectively and efficiently. One of them (I forget which)
has the code to still.ps, the germ from which Distiller grew.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.postscript


csiph-web